mercurial/httprepo.py
branchstable
changeset 10491 d7e582cab6b6
parent 10282 08a0f04b56bd
child 10525 cc2d296c1d4c
--- a/mercurial/httprepo.py	Tue Feb 16 21:04:04 2010 +0100
+++ b/mercurial/httprepo.py	Wed Feb 17 11:00:48 2010 +0100
@@ -74,10 +74,15 @@
         q.update(args)
         qs = '?%s' % urllib.urlencode(q)
         cu = "%s%s" % (self._url, qs)
+        req = urllib2.Request(cu, data, headers)
+        if data is not None:
+            # len(data) is broken if data doesn't fit into Py_ssize_t
+            # add the header ourself to avoid OverflowError
+            size = data.__len__()
+            self.ui.debug("sending %s bytes\n" % size)
+            req.add_unredirected_header('Content-Length', '%d' % size)
         try:
-            if data:
-                self.ui.debug("sending %s bytes\n" % len(data))
-            resp = self.urlopener.open(urllib2.Request(cu, data, headers))
+            resp = self.urlopener.open(req)
         except urllib2.HTTPError, inst:
             if inst.code == 401:
                 raise util.Abort(_('authorization failed'))