The WSGI input stream, with safety checks. This stream can only be consumed once. Use :meth:`get_data` to get the full data as bytes or text. The :attr:`data` attribute will contain the full bytes only if they do not represent form data. The :attr:`form` attribute wi
(self)
| 317 | |
| 318 | @cached_property |
| 319 | def stream(self) -> t.IO[bytes]: |
| 320 | """The WSGI input stream, with safety checks. This stream can only be consumed |
| 321 | once. |
| 322 | |
| 323 | Use :meth:`get_data` to get the full data as bytes or text. The :attr:`data` |
| 324 | attribute will contain the full bytes only if they do not represent form data. |
| 325 | The :attr:`form` attribute will contain the parsed form data in that case. |
| 326 | |
| 327 | Unlike :attr:`input_stream`, this stream guards against infinite streams or |
| 328 | reading past :attr:`content_length` or :attr:`max_content_length`. |
| 329 | |
| 330 | If ``max_content_length`` is set, it can be enforced on streams if |
| 331 | ``wsgi.input_terminated`` is set. Otherwise, an empty stream is returned. |
| 332 | |
| 333 | If the limit is reached before the underlying stream is exhausted (such as a |
| 334 | file that is too large, or an infinite stream), the remaining contents of the |
| 335 | stream cannot be read safely. Depending on how the server handles this, clients |
| 336 | may show a "connection reset" failure instead of seeing the 413 response. |
| 337 | |
| 338 | .. versionchanged:: 2.3 |
| 339 | Check ``max_content_length`` preemptively and while reading. |
| 340 | |
| 341 | .. versionchanged:: 0.9 |
| 342 | The stream is always set (but may be consumed) even if form parsing was |
| 343 | accessed first. |
| 344 | """ |
| 345 | if self.shallow: |
| 346 | raise RuntimeError( |
| 347 | "This request was created with 'shallow=True', reading" |
| 348 | " from the input stream is disabled." |
| 349 | ) |
| 350 | |
| 351 | return get_input_stream( |
| 352 | self.environ, max_content_length=self.max_content_length |
| 353 | ) |
| 354 | |
| 355 | input_stream = environ_property[t.IO[bytes]]( |
| 356 | "wsgi.input", |
nothing calls this directly
no test coverage detected