[Patches] [ python-Patches-430706 ] Persistent connections in BaseHTTPServer
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 21 Sep 2001 15:01:20 -0700
Patches item #430706, was opened at 2001-06-06 08:33
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=430706&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Lawrence (lordsutch)
Assigned to: Martin v. Löwis (loewis)
Summary: Persistent connections in BaseHTTPServer
Initial Comment:
This patch provides HTTP/1.1 persistent
connection support in BaseHTTPServer.py. It is
not enabled by default (for backwards
compatibility) because Content-Length headers
must be supplied for persistent connections to
work correctly.
----------------------------------------------------------------------
>Comment By: Chris Lawrence (lordsutch)
Date: 2001-09-21 15:01
Message:
Logged In: YES
user_id=6757
I've tracked that one down and will have an updated patch in
a day or two... basically it just needs another else
condition to handle the empty readline(). There are also
some issues for subclasses that probably need to be
documented to play nicely with bad clients like wget that
claim to be HTTP 1.0 but do HTTP 1.1 stuff.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-09-18 09:36
Message:
Logged In: YES
user_id=21627
It still doesn't work right. If I access SimpleHTTPServer
from a Netscape client, I get error messages like
localhost - - [18/Sep/2001 18:32:22] code 400, message Bad
request syntax ('')
localhost - - [18/Sep/2001 18:32:22] "" 400 -
These are caused because the client closes the connection
after the first request (likely, after it finds out that the
document it got contains no references to the same server
anymore). However, the server continues to invoke
handle_one_request, which reads the empty line and fails to
recognize that the client has closed the connection.
----------------------------------------------------------------------
Comment By: Chris Lawrence (lordsutch)
Date: 2001-09-15 01:15
Message:
Logged In: YES
user_id=6757
I reworked the patch a bit to ensure HTTP 1.1 mode is only
used if the handler class is in HTTP 1.1 mode, and
modified the test() functions in the server classes to add
a "protocol" option. I also modified SimpleHTTPServer to
send Content-Length headers for the implemented classes.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-09-04 04:40
Message:
Logged In: YES
user_id=21627
The patch in its current form seems to be broken. To see the
problem, please run SimpleHTTPServer on some directory, then
access it with a HTTP/1.1 client (e.g. Netscape 4.7).
The server will use the protocol version HTTP/1.0, but the
client will initially send 1.1, and send a Connection:
Keep-alive header. As a result, self.close_connection is set
to 0, despite using HTTP/1.0. In turn, the HTTP server won't
send a content length, and won't close the connection
either. Netscape waits forever from some completion which
never occurs, since the server waits for the next request on
the same connection.
It might be useful to enhance the SimpleHTTPServer test()
function to optionally operate in HTTP/1.1 mode (including
sending a proper ContentLength). Doing the same for the CGI
HTTP server is probably less useful.
----------------------------------------------------------------------
Comment By: Chris Lawrence (lordsutch)
Date: 2001-08-29 20:21
Message:
Logged In: YES
user_id=6757
I have updated the patch against current CVS and have added
documentation.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-08-08 13:43
Message:
Logged In: YES
user_id=21627
I haven't studied the patch in detail, yet, but I have a
few comments on the style:
- there is no need to quote all authors of the RFC. Also,
the reference to long-ago expired HTTP draft should go;
just replace it with a single reference to the RFC
number (giving an URL for the RFC might be convenient)
- Where is the documentation? A patch to
Doc/lib/libbasehttp.tex would be appreciated. If you don't
speak TeX, don't worry: Just write plain text, we'll do
the mark-up.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=430706&group_id=5470