changeset 2557:1727ff712a4e

Fix push over https. Without this patch, python gives me a TypeError: write() argument 1 must be string or read-only buffer, not file
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 03 Jul 2006 00:23:58 -0300
parents f1ebc4311f47
children 1120302009d7
files mercurial/httprepo.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprepo.py	Mon Jul 03 00:23:56 2006 -0300
+++ b/mercurial/httprepo.py	Mon Jul 03 00:23:58 2006 -0300
@@ -91,6 +91,22 @@
     def http_open(self, req):
         return self.do_open(httpconnection, req)
 
+class httpsconnection(httplib.HTTPSConnection):
+    # must be able to send big bundle as stream.
+
+    def send(self, data):
+        if isinstance(data, str):
+            httplib.HTTPSConnection.send(self, data)
+        else:
+            # if auth required, some data sent twice, so rewind here
+            data.seek(0)
+            for chunk in util.filechunkiter(data):
+                httplib.HTTPSConnection.send(self, chunk)
+
+class httpshandler(urllib2.HTTPSHandler):
+    def https_open(self, req):
+        return self.do_open(httpsconnection, req)
+
 class httprepository(remoterepository):
     def __init__(self, ui, path):
         self.caps = None
@@ -160,6 +176,7 @@
 
         opener = urllib2.build_opener(
             handler,
+            httpshandler(),
             urllib2.HTTPBasicAuthHandler(passmgr),
             urllib2.HTTPDigestAuthHandler(passmgr))