Hi, I'm new to this group. I'm using web.py for a customers portal I'm working on. I've found what seems like a bug in how static files are served in windows. Although the production server will be Linux, I'm testing locally in Windows for development.
The manifestation of the bug is that accessing any static text file (localhost:8080/static/main.css) from the browser causes a 10-second delay, leaving the browser's spinning wheel spinning for 10 seconds, until the server times out and closes the connection. The content of the file is received immediately, but the connections stays open, with the client waiting for more stuff. in the end, after the end of the file, the following is sent by the sever before closing the connection: HTTP/1.1 408 Request Timeout Content-Length: 0 Content-Type: text/plain I've tracked it down, and found out that it only happens for CRLF- terminated text files in /static/. The reason is that the HTTP response header is sent with a "Content-length" calculated from the length of the file (see lib/SimpleHTTPServer.py lines 94-95 (I'm using Python 2.5), but the file is open in 'r' mode (ASCII), by which the OS transforms the CRLF pairs in LFs, and so, less bytes are sent than the HTTP header's Content-length promises. Fixes/workarounds are simple: never use CRLF terminators in static text files, change the file opening mode from 'r' to 'rb' in line 84 in the above mentioned file, etc... but I think this is a bug in SimpleHTTPServer.py, and should be fixed "upstream". I dunno how to go about this, so I'd be grateful for any help in reporting this or getting it officially fix. Apart from this, I think web.py itself has some kind of problem, because it resents the header as if nothing had been sent, and actually part of the response has been sent (both the header and a big chunk of data). Web.py would probably like to handle this in some other way. It's easy to reproduce the problem in non-windows systems if you insert a return statement in httpserver.py, line 182. This is in the __iter__ method of class StaticApp inside runsimple, right before starting to read chunks of the file and sending them down the pipe. The result will be the same -- both the browser client and the server will stay spinning, waiting for the data, and will end up badly with a timeout on the server and the erroneous in-band HTTP 408 headers being sent. Thanks and best regards, Jon Beltran de Heredia Symnum Systems (f/ NGEDIT Software) http://blog.ngedit.com http://www.viemu.com - vi/vim emulation for Visual Studio, SQL Server, Word and Outlook http://www.codekana.com - Codekana - C/C++/C# Code Visualization for Visual Studio --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
