[Python-bugs-list] [ python-Bugs-622042 ] httplib HEAD request fails - keepalive

noreply@sourceforge.net noreply@sourceforge.net
Tue, 15 Oct 2002 06:44:56 -0700


Bugs item #622042, was opened at 2002-10-11 16:15
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=622042&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Mihai Ibanescu (misa)
Assigned to: Jeremy Hylton (jhylton)
Summary: httplib HEAD request fails - keepalive

Initial Comment:
httplib fails to handle HEAD requests correctly when
the server side honors a keep-alive connection.

Per RFC2616, sect. 9.4:

<quot>
The HEAD method is identical to GET except that the
server MUST NOT return a message-body in the response.
The metainformation contained in the HTTP headers in
the response to a HEAD request SHOULD be identical to
the information sent in response to a GET request.
</quot>

This means that HEAD requests are likely to return a
non-zero Content-Length, but with no body.

The attached script, if called against an HTTP/1.1,
keep-alive-aware server (try www.microsoft.com or
www.redhat.com) will hang instead of finishing, because
read() will expect to read some bytes from the connection.

The script was tested against version 1.66 of httplib
(the current HEAD).

HTTP/1.0 and Connection: close (with HTTP/1.1) work as
expected because the server closes the connection.

----------------------------------------------------------------------

>Comment By: Mihai Ibanescu (misa)
Date: 2002-10-15 09:44

Message:
Logged In: YES 
user_id=205865

Yes, I will upload the patch as soon as possible.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-10-14 19:57

Message:
Logged In: YES 
user_id=6380

Sure seems that way. ;-(  For example this hangs:

  python2.3 http-request.py python.org

while this returns correctly:

  python2.3 http-request.py zope.com

Mihai, do you have a proposed fix?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=622042&group_id=5470