Skip to content

Commit daae608

Browse files
committed
Clarify behaviour when reading past content-length
1 parent 2c23fb5 commit daae608

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

proposal.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,17 +738,23 @@ The semantics of each method are as documented in the Python Library
738738
Reference, except for these notes as listed in the table above:
739739

740740
1. The server is not required to read past the client's specified
741-
``Content-Length``, and **should** simulate an end-of-file
742-
condition if the application attempts to read past that point.
743-
The application **should not** attempt to read more data than is
744-
specified by the ``CONTENT_LENGTH`` variable.
741+
``Content-Length``, and **may** simulate an end-of-file
742+
condition if the application attempts to read past that point. However, if
743+
the server has reason to believe that more data exists, or if
744+
``Content-Length`` does not apply for this body (e.g. because the body uses
745+
chunked transfer-encoding, or because it is a HTTP/1.0 request with no
746+
content-length), the server **may** allow reads beyond ``Content-Length``.
745747

746748
A server **should** allow ``read()`` to be called without an argument,
747749
and return the remainder of the client's input stream.
748750

749-
A server **should** return empty bytestrings from any attempt to
751+
A server **must** return empty bytestrings from any attempt to
750752
read from an empty or exhausted input stream.
751753

754+
The consequence of these requirements is that an application may choose to
755+
disregard the ``CONTENT_LENGTH`` variable, and instead read until the
756+
end-of-file condition (returning an empty bytestring) is encountered.
757+
752758
2. Servers **should** support the optional "size" argument to ``readline()``,
753759
but as in WSGI 1.0, they are allowed to omit support for it.
754760

0 commit comments

Comments
 (0)