| 142 | response: t.Iterable[str] | t.Iterable[bytes] |
| 143 | |
| 144 | def __init__( |
| 145 | self, |
| 146 | response: t.Iterable[bytes] | bytes | t.Iterable[str] | str | None = None, |
| 147 | status: int | str | HTTPStatus | None = None, |
| 148 | headers: t.Mapping[str, str | t.Iterable[str]] |
| 149 | | t.Iterable[tuple[str, str]] |
| 150 | | None = None, |
| 151 | mimetype: str | None = None, |
| 152 | content_type: str | None = None, |
| 153 | direct_passthrough: bool = False, |
| 154 | ) -> None: |
| 155 | super().__init__( |
| 156 | status=status, |
| 157 | headers=headers, |
| 158 | mimetype=mimetype, |
| 159 | content_type=content_type, |
| 160 | ) |
| 161 | |
| 162 | #: Pass the response body directly through as the WSGI iterable. |
| 163 | #: This can be used when the body is a binary file or other |
| 164 | #: iterator of bytes, to skip some unnecessary checks. Use |
| 165 | #: :func:`~werkzeug.utils.send_file` instead of setting this |
| 166 | #: manually. |
| 167 | self.direct_passthrough = direct_passthrough |
| 168 | self._on_close: list[t.Callable[[], t.Any]] = [] |
| 169 | |
| 170 | # we set the response after the headers so that if a class changes |
| 171 | # the charset attribute, the data is set in the correct charset. |
| 172 | if response is None: |
| 173 | self.response = [] |
| 174 | elif isinstance(response, (str, bytes, bytearray)): |
| 175 | self.set_data(response) |
| 176 | else: |
| 177 | self.response = response |
| 178 | |
| 179 | def call_on_close(self, func: t.Callable[[], t.Any]) -> t.Callable[[], t.Any]: |
| 180 | """Adds a function to the internal list of functions that should |