Mercurial > hg-stable
changeset 8146:4f13ed6ee544
keepalive: attempt to fix issue1003
This is a reimport of the relevant piece of the upstream urlgrabber,
which appears to be more correct.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 23 Apr 2009 15:40:10 -0500 |
parents | 0c2ba48415c8 |
children | 441dc7becd43 |
files | mercurial/keepalive.py |
diffstat | 1 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/keepalive.py Thu Apr 23 15:40:10 2009 -0500 +++ b/mercurial/keepalive.py Thu Apr 23 15:40:10 2009 -0500 @@ -307,15 +307,28 @@ return r def _start_transaction(self, h, req): - headers = req.headers.copy() - body = req.data - if sys.version_info >= (2, 4): - headers.update(req.unredirected_hdrs) try: - h.request(req.get_method(), req.get_selector(), body, headers) - except socket.error, err: # XXX what error? + if req.has_data(): + data = req.get_data() + h.putrequest('POST', req.get_selector()) + if 'Content-type' not in req.headers: + h.putheader('Content-type', + 'application/x-www-form-urlencoded') + if 'Content-length' not in req.headers: + h.putheader('Content-length', '%d' % len(data)) + else: + h.putrequest('GET', req.get_selector()) + except (socket.error), err: raise urllib2.URLError(err) + for args in self.parent.addheaders: + h.putheader(*args) + for k, v in req.headers.items(): + h.putheader(k, v) + h.endheaders() + if req.has_data(): + h.send(data) + class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler): pass