mercurial/keepalive.py
changeset 8146 4f13ed6ee544
parent 7875 553aa0cbeab6
child 8233 655c435efe92
--- 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