[Patches] [ python-Patches-498149 ] httplib.py screws up on 100 response

noreply@sourceforge.net noreply@sourceforge.net
Mon, 31 Dec 2001 11:14:54 -0800


Patches item #498149, was opened at 2001-12-31 11:13
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=498149&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jens B. Jorgensen (jensbjorgensen)
>Assigned to: Greg Stein (gstein)
Summary: httplib.py screws up on 100 response

Initial Comment:
Bug 227361 details a problem where httplib.py behaves
poorly when a server returns an HTTP 100 response code.
This is pretty annoying since Microsoft IIS ASP pages
are notorious for first returning a 100 code and then
returning the "real" response. What is worse,
httplib.py sets the self.__state to a value which
prevents you from trying to get the next response so
you can get the value. Once you get the 100 response
code your object is stuck and you have no way of
getting the response. 

I needed to solve this problem and did so. I found that
a bug had been logged and that the assignee (and
maintainer?) indicated a preference for a solution
where the HTTPResponse object would transparently
consume the 100 responses in the begin() method. My
simple change adopts this philosophy and does just
that. It will loop, consuming 100 responses until a
non-100 response is return. For the curious, yes,
servers can be observed returning more than one 100
response. All header information returned in the 100
responses is overwritten and lost. I don't think this
will be much of a concern for anyone. I also concur
that transparently consuming the 100 responses is the
most appropriate thing to do. It's clean, doesn't seem
to have any obvious gothchas (haven't thought about how
it could affect proxies or the like) and will prevent
everyone from having to, say, write their own loops to
chew through the 100 responses on their own. 

I've really only added 4 lines even though the patch is
bigger. I just did one quick test with the change to
the CVS version since that's not the version that I'm
using but the changes are really slight so I'm not too
worried.

And finally, I'm using:

TALLAN2$ python
ActivePython 2.1, build 211 (ActiveState)
based on Python 2.1 (#15, Jun 18 2001, 21:42:28) [MSC
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.



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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=498149&group_id=5470