# HG changeset patch # User Patrick Mezard # Date 1240863336 -7200 # Node ID 655c435efe92c2457894e86fb62621a41f8c17a2 # Parent 823f25b25deae4deae0a7cbde450ea6157935792 keepalive: fix 4f13ed6ee544, reintroduce unredirected_hdrs The previous fix dropped unredirected_hdrs which contain authentication headers. Removing them break POST request requiring authentication (like unbundle calls to bitbucket.org). diff -r 823f25b25dea -r 655c435efe92 mercurial/keepalive.py --- a/mercurial/keepalive.py Sun Apr 26 01:57:12 2009 +0200 +++ b/mercurial/keepalive.py Mon Apr 27 22:15:36 2009 +0200 @@ -307,23 +307,31 @@ return r def _start_transaction(self, h, req): + # What follows mostly reimplements HTTPConnection.request() + # except it adds self.parent.addheaders in the mix. + headers = req.headers.copy() + if sys.version_info >= (2, 4): + headers.update(req.unredirected_hdrs) + headers.update(self.parent.addheaders) + headers = dict((n.lower(), v) for n,v in headers.items()) + skipheaders = {} + for n in ('host', 'accept-encoding'): + if n in headers: + skipheaders['skip_' + n.replace('-', '_')] = 1 try: if req.has_data(): data = req.get_data() - h.putrequest('POST', req.get_selector()) - if 'Content-type' not in req.headers: + h.putrequest('POST', req.get_selector(), **skipheaders) + if 'content-type' not in headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') - if 'Content-length' not in req.headers: + if 'content-length' not in headers: h.putheader('Content-length', '%d' % len(data)) else: - h.putrequest('GET', req.get_selector()) + h.putrequest('GET', req.get_selector(), **skipheaders) except (socket.error), err: raise urllib2.URLError(err) - - for args in self.parent.addheaders: - h.putheader(*args) - for k, v in req.headers.items(): + for k, v in headers.items(): h.putheader(k, v) h.endheaders() if req.has_data():