Skip to content
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

Allow chunk encoded HTTP requests Fixes #1094 #1095

Closed
Closed
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
14 changes: 4 additions & 10 deletions werkzeug/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_content_length(environ):
pass


def get_input_stream(environ, safe_fallback=True):
def get_input_stream(environ):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
Expand All @@ -188,10 +188,6 @@ def get_input_stream(environ, safe_fallback=True):
.. versionadded:: 0.9

:param environ: the WSGI environ to fetch the stream from.
:param safe: indicates whether the function should use an empty
stream as safe fallback or just return the original
WSGI input stream if it can't wrap it safely. The
default is to return an empty string in those cases.
"""
stream = environ['wsgi.input']
content_length = get_content_length(environ)
Expand All @@ -202,12 +198,10 @@ def get_input_stream(environ, safe_fallback=True):
if environ.get('wsgi.input_terminated'):
return stream

# If we don't have a content length we fall back to an empty stream
# in case of a safe fallback, otherwise we return the stream unchanged.
# The non-safe fallback is not recommended but might be useful in
# some situations.
# If we don't have a content length we return the stream unchanged.
# PEP3333 only requires a limited stream if CONTENT_LENGTH is present.
if content_length is None:
return safe_fallback and _empty_stream or stream
return stream

# Otherwise limit the stream to the content length
return LimitedStream(stream, content_length)
Expand Down