2009/1/26 Clodoaldo Pinto Neto <[email protected]>:
>
> 2009/1/26 Graham Dumpleton <[email protected]>:
>>
>> 2009/1/26 Clodoaldo Pinto Neto <[email protected]>:
>>>> Regarding the line:
>>>>
>>>>  s = environ['wsgi.input'].read().decode('latin1')
>>>>
>>>> First off, this is not WSGI compliant. To be compliant with WSGI
>>>> specification you must supply a length to read() when it is called on
>>>> wsgi.input.
>>>>
>>>> I want you to first off replace that line with:
>>>>
>>>>  length = int(environ.get("CONTENT_LENGTH", "0"))
>>>
>>> Didn't test with modwsgi but with python built in wsgi server that is
>>> not enough since it sets CONTENT_LENGTH to empty so this is necessary:
>>>
>>>   try:
>>>      length = int(environ['CONTENT_LENGTH'])
>>>   except (TypeError, ValueError):
>>>      length = 0
>>
>> Which version of Python?
>
> 2.5.2.
>
>>
>> I would have expected CONTENT_LENGTH being set to an empty string to
>> be a bug and probably in violation of CGI specification which WSGI
>> relies upon.
>
> From the PEP 333:
>
> "CONTENT_LENGTH
>    The contents of any Content-Length fields in the HTTP request. May
> be empty or absent."

Hmmm, I stand corrected. From memory, means I have seen a lot of
broken WSGI code around the place then. :-)

Instead of exceptions, how about using:

  int(environ.get("CONTENT_LENGTH", "0") or "0")

Graham

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to