[Python-checkins] python/dist/src/Lib httplib.py,1.85,1.86
jhylton at users.sourceforge.net
jhylton at users.sourceforge.net
Sat Aug 7 18:28:16 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15119
Modified Files:
httplib.py
Log Message:
SF bug 874842 and patch 997626: httplib bugs
Hack httplib to work with broken Akamai proxies.
Make sure that httplib doesn't add extract Accept-Encoding or
Content-Length headers if the client has already set them.
Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** httplib.py 5 Jun 2004 13:30:56 -0000 1.85
--- httplib.py 7 Aug 2004 16:28:13 -0000 1.86
***************
*** 345,348 ****
--- 345,349 ----
def _check_close(self):
+ conn = self.msg.getheader('connection')
if self.version == 11:
# An HTTP/1.1 proxy is assumed to stay open unless
***************
*** 353,358 ****
return False
! # An HTTP/1.0 response with a Connection header is probably
! # the result of a confused proxy. Ignore it.
# For older HTTP, Keep-Alive indiciates persistent connection.
--- 354,359 ----
return False
! # Some HTTP/1.0 implementations have support for persistent
! # connections, using rules different than HTTP/1.1.
# For older HTTP, Keep-Alive indiciates persistent connection.
***************
*** 360,363 ****
--- 361,369 ----
return False
+ # At least Akamai returns a "Connection: Keep-Alive" header,
+ # which was supposed to be sent by the client.
+ if conn and "keep-alive" in conn.lower():
+ return False
+
# Proxy-Connection is a netscape hack.
pconn = self.msg.getheader('proxy-connection')
***************
*** 382,385 ****
--- 388,393 ----
return self.fp is None
+ # XXX It would be nice to have readline and __iter__ for this, too.
+
def read(self, amt=None):
if self.fp is None:
***************
*** 729,741 ****
def _send_request(self, method, url, body, headers):
! # If headers already contains a host header, then define the
! # optional skip_host argument to putrequest(). The check is
! # harder because field names are case insensitive.
! if 'host' in [k.lower() for k in headers]:
! self.putrequest(method, url, skip_host=1)
! else:
! self.putrequest(method, url)
! if body:
self.putheader('Content-Length', str(len(body)))
for hdr, value in headers.iteritems():
--- 737,751 ----
def _send_request(self, method, url, body, headers):
! # honour explicitly requested Host: and Accept-Encoding headers
! header_names = dict.fromkeys([k.lower() for k in headers])
! skips = {}
! if 'host' in header_names:
! skips['skip_host'] = 1
! if 'accept-encoding' in header_names:
! skips['skip_accept_encoding'] = 1
! self.putrequest(method, url, **skips)
!
! if body and ('content-length' not in header_names):
self.putheader('Content-Length', str(len(body)))
for hdr, value in headers.iteritems():
More information about the Python-checkins
mailing list