Mercurial > hg
diff mercurial/keepalive.py @ 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 | 553aa0cbeab6 |
children | 655c435efe92 |
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