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

Signal WSGI app that the input is terminated #66

Merged
merged 1 commit into from Feb 3, 2018

Conversation

Projects
None yet
2 participants
@webknjaz
Member

webknjaz commented Dec 2, 2017

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

    • Feature
  • What is the related issue number (starting with #)

  • What is the current behavior? (You can also link to an open issue here)
    'wsgi.input_terminated' WSGI env var is not set.

  • What is the new behavior (if this is a feature change)?
    'wsgi.input_terminated' WSGI env var is set if the Transfer-Encoding is chunked.

  • Other information:
    This PR sets env['wsgi.input_terminated'] = True if the request uses
    chunked Transfer-Encoding, so that WSGI app would know that it's safe
    to read from env['wsgi.input'] stream.

It implements @mitsuhiko's proposal:
https://gist.github.com/mitsuhiko/5721547

///
@davidism and @jaraco please review.

@webknjaz webknjaz added the enhancement label Dec 2, 2017

@webknjaz webknjaz self-assigned this Dec 2, 2017

@webknjaz webknjaz requested a review from jaraco Dec 2, 2017

@@ -249,6 +249,7 @@ def get_environ(self):
'SERVER_SOFTWARE': req.server.software,
'wsgi.errors': sys.stderr,
'wsgi.input': req.rfile,
'wsgi.input_terminated': bool(self.req.chunked_read),

This comment has been minimized.

@davidism

davidism Dec 2, 2017

Don't need self here.

This comment has been minimized.

@webknjaz

webknjaz Dec 2, 2017

Member

Oh.. you're right

@davidism

This comment has been minimized.

davidism commented Dec 2, 2017

Is chunked_read the only time cheroot terminates input? If it also limits the stream when Content-Length is present, you can set wsgi.input_terminated then too, for example.

Signal WSGI app that the input is terminated
Sets ``env['wsgi.input_terminated'] = True`` if the request uses
chunked Transfer-Encoding, so that WSGI app would know that it's safe
to read from ``env['wsgi.input']`` stream.

Implements @mitsuhiko's proposal:
https://gist.github.com/mitsuhiko/5721547

Ref: cherrypy/cherrypy#1664
Ref: Pylons/webob#278
Ref: unbit/uwsgi#1428

@webknjaz webknjaz force-pushed the feature/wsgi.input_terminated branch from 4b9dff1 to 23c98b3 Dec 2, 2017

@stale

This comment has been minimized.

stale bot commented Jan 31, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 31, 2018

@davidism

This comment has been minimized.

davidism commented Jan 31, 2018

@webknjaz this looks fine, my earlier comment was just that more could be done, but that isn't requried. This should be ok to merge.

@stale stale bot removed the stale label Jan 31, 2018

@webknjaz

This comment has been minimized.

Member

webknjaz commented Feb 3, 2018

Thanks!

@webknjaz webknjaz merged commit 7f4cef8 into master Feb 3, 2018

8 of 9 checks passed

ci/circleci Your tests failed on CircleCI
Details
WIP ready for review
Details
codeclimate All good!
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
lgtm analysis: Python No alert changes
Details
pyup.io/safety-ci No dependencies with known security vulnerabilities.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment