[Web-SIG] CherryPy WSGI server and wsgi.input.read() with no argument.

Ian Bicking ianb at colorstudy.com
Fri Mar 30 02:19:44 CEST 2007


Graham Dumpleton wrote:
> ""The application should not attempt to read more data than is
> specified by the CONTENT_LENGTH variable."""
> 
> is actually a bit bogus.
> 
> This is because a WSGI middleware component or web server could be
> acting as an input filter and decompressing a content encoding of gzip
> for request. Since it knows the size will change but will not know
> what the new size would be, except by buffering it all, it by rights
> should remove CONTENT_LENGTH. This presents a problem for an
> application as no CONTENT_LENGTH then to rely on to know whether it
> has read to much input. If you leave CONTENT_LENGTH intact, it may
> think it has read everything when there is in fact more.

I thought leaving it out might be a good way to indicate 
content-length-unknown, but now I'm not so sure.  I think a better 
indication is "-1", which works with cgi.FieldStorage and lots of other 
code, and generally .read(-1) means "give me everything you have".


-- 
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
             | Write code, do good | http://topp.openplans.org/careers


More information about the Web-SIG mailing list