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

Added support for chunked encoded requests when running gunicorn. #340 #405

Merged
merged 2 commits into from
Dec 18, 2017

Conversation

javabrett
Copy link
Contributor

In this commit:

  • when we see a Transfer-Encoding: chunked request, and the server is gunicorn,
    we set environ wsgi.input_terminated, which is required by Werkzeug in the
    absence of Content-Lenght, or it will empty the data stream.
  • for chunked requests to non-gunicorn, return 501 Not Implemented.

Looking for guidance on the best way to set-up an acceptance/system test for this, since it cannot be verified through unit tests using FlaskClient.

httpbin/core.py Outdated
server = request.environ.get('SERVER_SOFTWARE', '')
if server.lower().startswith('gunicorn/'):
if 'wsgi.input_terminated' in request.environ:
app.logger.warning("environ wsgi.input_terminated already set, keeping: %s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really a warning level message? I'd consider this INFO or DEBUG at best.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes debug is better and I have changed to that and rebased to master.

The original thinking of a louder log message was to quickly catch a change in gunicorn if it started adding input_terminated to requests, deprecating this middleware. But debug is fine for this.

postmanlabs#340.

In this commit:

- when we see a Transfer-Encoding: chunked request, and the server is gunicorn,
  we set environ wsgi.input_terminated, which is required by Werkzeug in the
  absence of Content-Lenght, or it will empty the data stream.
- for chunked requests to non-gunicorn, return 501 Not Implemented.
@kennethreitz kennethreitz merged commit c0f5f0a into postmanlabs:master Dec 18, 2017
@kennethreitz
Copy link
Contributor

✨🍰✨

@javabrett javabrett deleted the support-chunked-340 branch May 5, 2018 06:56
virgiliojr94 pushed a commit to virgiliojr94/httpbin-chat2desk that referenced this pull request Jul 1, 2023
Added support for chunked encoded requests when running gunicorn. postmanlabs#340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants