[Web-SIG] environ["wsgi.input"].read()

Graham Dumpleton graham.dumpleton at gmail.com
Sun Jan 27 23:41:45 CET 2008


On 28/01/2008, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> On 28/01/2008, Brian Smith <brian at briansmith.org> wrote:
> > Graham Dumpleton wrote:
> > > On 26/01/2008, Brian Smith <brian at briansmith.org> wrote:
> > > As to your questions about read() with no argument, or with
> > > traditional Python file like object default of -1, the only
> > > WSGI server/adapter I know of where this will NOT work as one
> > > would expect, ie., read remainder of request content, is the
> > > CherryPy WSGI adapter.
> > >
> > > As far as I know it works fine with Apache CGI WSGI adapters,
> > > Apache mod_wsgi, plus SCGI, FASTCGI and AJP adapters via
> > > flup, as well as with paste WSGI server. Not sure what
> > > wsgiref will do though.
> >
> > It doesn't work on mod_wsgi either. When I tried it, it only returned
> > 8000 bytes of the input. That is why I started this thread in the first
> > place, actually. If this isn't the behavior you expected, I will file a
> > bug with a test case. (Google Code doesn't allow for attachments to bug
> > reports too, maybe I will create my own "WSGI testcases" project on
> > Google Code to store them all in SVN.)
>
> Whoops, you are right.
>
> Very very early development versions of mod_wsgi would read
> everything, but for some reason I changed tack as was experimenting
> with read() with no argument returning only what was actually
> available at that time, possibly to see how input chunking could work.
> Ie., simulating a non blocking read. I thought I had put it back to
> read everything. Obviously I completely forgot what I was doing. :-(

Okay, what I am going to do with Apache mod_wsgi is simply enforce the
requirement that an argument be supplied to read(). After all, the
WSGI PEP says there has to be an argument.

It will be interesting to see whether any WSGI applications or
commonly used modules then start failing. If some major modules start
failing, it will at least show that not allowing the argument to be
optional may have to be reviewed. :-)

Graham


More information about the Web-SIG mailing list