[Web-SIG] Is the size argument to the input-stream read method optional?

Jim Fulton jim at zope.com
Wed Dec 21 18:38:26 CET 2005


Phillip J. Eby wrote:
> At 10:20 AM 12/21/2005 -0500, Jim Fulton wrote:
> 
>> Ian Bicking wrote:
>> > Jim Fulton wrote:
>> >
>> >> The PEP is unclear on this and should be clarified, IMO.
>> >
>> >
>> > My experience in using implementations is many servers do not require
>> > the read size argument (they don't give a TypeError), but they block
>> > without it, or if you read past CONTENT_LENGTH.  So it should probably
>> > be required in the spec, since it's required in practice.
>>
>> Does this constitude a decision?  Can somebody update the PEP?
> 
> 
> I thought the PEP was actually pretty clear on this already.  It says 
> that the application should not attempt to read more data than is 
> specified by CONTENT_LENGTH - which means that you can't omit the read() 
> argument and avoid that.  An application that omits the argument is 
> therefore off-spec, and a server is thus well within its rights to 
> reject this.  As far as I know, there is also no circumstance under 
> which a previously-working application (using CGI or some similar 
> protocol) would be able to use read() without an argument and work 
> correctly with any non-ancient version of HTTP.

In Zope and twisted's wsgi server implementation, the input read method
treats the character at position content length (counting from 1) as the
last character in the file.  So read without argument reads the remaining
characters up to the content length.  This isn't inconsistent with the
current language.

> I'm happy to entertain suggestions for language that would make this 
> more obvious.  How about just adding """The "size" argument is required 
> and must be a positive integer.""" to the existing note 1?

I think this is an improvement. +1.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Web-SIG mailing list