This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rschoon
Recipients rschoon
Date 2014-06-28.06:35:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403937301.18.0.584032434522.issue21878@psf.upfronthosting.co.za>
In-reply-to
Content
In the reference WSGI server in wsgiref.simple_server, wsgi.input's readline() hangs if the request body does not actually contain any
newlines.

Consider the following (slightly silly) example:

    from wsgiref.simple_server import make_server

    def app(environ, start_response):
        result = environ['wsgi.input'].readline()

        # not reached...
        start_response("200 OK", [("Content-Type", "text/plain")])
        return []

    httpd = make_server('', 8000, app)
    httpd.serve_forever()

And the following also silly request (the data kwarg makes it a
POST request):

    from urllib.request import urlopen

    req = urlopen("http://localhost:8000/", data=b'some bytes')
    print(req)

Normally this isn't a problem, as the reference server isn't intended
for production, and typically the only reason .readline() would be
used is with a request body formatted as multipart/form-data, which
uses ample newlines, including with the content boundaries.  However,
for other types of request bodies (such as application/x-www-form-urlencoded)
newlines often wouldn't appear, and using .readline() would wait forever for new input.
History
Date User Action Args
2014-06-28 06:35:01rschoonsetrecipients: + rschoon
2014-06-28 06:35:01rschoonsetmessageid: <1403937301.18.0.584032434522.issue21878@psf.upfronthosting.co.za>
2014-06-28 06:35:01rschoonlinkissue21878 messages
2014-06-28 06:35:00rschooncreate