Return the ``Content-Length`` header value as an int. If the header is not given or the ``Transfer-Encoding`` header is ``chunked``, ``None`` is returned to indicate a streaming request. If the value is not an integer, or negative, 0 is returned. :param environ: The WSGI environ to get
(environ: WSGIEnvironment)
| 126 | |
| 127 | |
| 128 | def get_content_length(environ: WSGIEnvironment) -> int | None: |
| 129 | """Return the ``Content-Length`` header value as an int. If the header is not given |
| 130 | or the ``Transfer-Encoding`` header is ``chunked``, ``None`` is returned to indicate |
| 131 | a streaming request. If the value is not an integer, or negative, 0 is returned. |
| 132 | |
| 133 | :param environ: The WSGI environ to get the content length from. |
| 134 | |
| 135 | .. versionadded:: 0.9 |
| 136 | """ |
| 137 | return _sansio_utils.get_content_length( |
| 138 | http_content_length=environ.get("CONTENT_LENGTH"), |
| 139 | http_transfer_encoding=environ.get("HTTP_TRANSFER_ENCODING"), |
| 140 | ) |
| 141 | |
| 142 | |
| 143 | def get_input_stream( |
no test coverage detected