Skip to content

Clarify behaviour when reading past content-length #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions proposal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -738,17 +738,23 @@ The semantics of each method are as documented in the Python Library
Reference, except for these notes as listed in the table above:

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

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

A server **should** return empty bytestrings from any attempt to
A server **must** return empty bytestrings from any attempt to
read from an empty or exhausted input stream.

The consequence of these requirements is that an application may choose to
disregard the ``CONTENT_LENGTH`` variable, and instead read until the
end-of-file condition (returning an empty bytestring) is encountered.

2. Servers **should** support the optional "size" argument to ``readline()``,
but as in WSGI 1.0, they are allowed to omit support for it.

Expand Down