@@ -738,17 +738,23 @@ The semantics of each method are as documented in the Python Library
738
738
Reference, except for these notes as listed in the table above:
739
739
740
740
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 ``.
745
747
746
748
A server **should ** allow ``read() `` to be called without an argument,
747
749
and return the remainder of the client's input stream.
748
750
749
- A server **should ** return empty bytestrings from any attempt to
751
+ A server **must ** return empty bytestrings from any attempt to
750
752
read from an empty or exhausted input stream.
751
753
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
+
752
758
2. Servers **should ** support the optional "size" argument to ``readline() ``,
753
759
but as in WSGI 1.0, they are allowed to omit support for it.
754
760
0 commit comments