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

pywsgi does not set wsgi.input_terminated for chunked data #1308

Closed
tzickel opened this Issue Nov 7, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@tzickel
Contributor

tzickel commented Nov 7, 2018

Basically the issue is:
https://gist.github.com/mitsuhiko/5721547

Some wsgi server already support it, since pywsgi supports passing a chunked encoding stream properly to the application ( PR #610 ), it should set the environ flag:
environ['wsgi.input_terminated'] = True

This will allow application side software like flask (or rather anything based off werkzeug) to actually get the body data in case of a chunked-stream instead of an empty stream:
https://github.com/pallets/werkzeug/blob/master/werkzeug/wsgi.py#L205

You can see a small test which cries:

from gevent import spawn
from gevent.pywsgi import WSGIServer
from gevent.socket import socket
import flask


app = flask.Flask(__name__)


@app.route('/', methods=['GET', 'POST'])
def index():
    # FAKE PATCH TO SHOW IT WORKS
    #flask.request.environ['wsgi.input_terminated'] = True
    if flask.request.get_data() == b'':
        print('I cry')
    return ''


server = WSGIServer(('localhost', 8080), app)
spawn(server.serve_forever)
s = socket()
s.connect(('localhost', 8080))
s.send(b'POST / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n2\r\nHi\r\n0\r\n\r\n')
print(s.recv(10000))
s.close()
server.close()
@jamadden

This comment has been minimized.

Member

jamadden commented Nov 7, 2018

Can you show me where the PEP defines this?

@jamadden jamadden closed this in 62e3ffe Nov 12, 2018

jamadden added a commit that referenced this issue Nov 12, 2018

Merge pull request #1312 from gevent/issue1308
Set the non-standard wsgi.input_terminated flag. Fixes #1308.

ricardokirkner pushed a commit to ricardokirkner/gevent that referenced this issue Nov 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment