Are the built-in HTTP servers production quality?

Paul Morrow pm_mon at yahoo.com
Sun Jul 18 13:27:37 EDT 2004


Irmen de Jong wrote:
> Paul Morrow wrote:
> 
>> Irmen de Jong wrote:
>>
>>>
>>> For starters, the SimpleHTTPServer reports the wrong Content-Length.
>>> See my patch at http://tinyurl.com/56frb
>>>
>>
>> Yes, something is wrong there.  I wonder though if it makes sense to 
>> continue to open text files in 'text' mode, so that the treatment of 
>> newlines is normalized, but then adjust the content-length to be the 
>> length of the (newline converted) string as read from the file.
>>
> 
> Well, I think that could be done too.
> But why not ditch the newline conversion altogether and
> treat text files just as any other file (which is what my patch does).
> 
> -Irmen

I'm not sure that we can rely on the client browser doing the right 
thing with the newlines.  I'm not aware of an rfc that really covers 
this, but do all browsers convert text files as needed to their native 
format?  If so, sending them as binary (unaltered) would be fine.  But 
if not, maybe the solution is to detect (or make a guess at) the OS of 
the client, then adjust the newlines accordingly (yuck!)...




More information about the Python-list mailing list