[PATCH 4 of 7] url: refactor _gen_sendfile

Mads Kiilerich mads at kiilerich.com
Tue Feb 15 21:41:25 CST 2011


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1297826897 -3600
# Node ID 442ece9fa5cbdaee638fa72053dee94e9104b8e3
# Parent  507fea07a4584e5921e86e66ad4be0b8cb2b0b20
url: refactor _gen_sendfile

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -291,16 +291,16 @@
     def __len__(self):
         return self._len
 
-def _gen_sendfile(connection):
+def _gen_sendfile(orgsend):
     def _sendfile(self, data):
         # send a file
         if isinstance(data, httpsendfile):
             # if auth required, some data sent twice, so rewind here
             data.seek(0)
             for chunk in util.filechunkiter(data):
-                connection.send(self, chunk)
+                orgsend(self, chunk)
         else:
-            connection.send(self, data)
+            orgsend(self, data)
     return _sendfile
 
 has_https = hasattr(urllib2, 'HTTPSHandler')
@@ -353,7 +353,7 @@
 
 class httpconnection(keepalive.HTTPConnection):
     # must be able to send big bundle as stream.
-    send = _gen_sendfile(keepalive.HTTPConnection)
+    send = _gen_sendfile(keepalive.HTTPConnection.send)
 
     def connect(self):
         if has_https and self.realhostport: # use CONNECT proxy
@@ -595,7 +595,7 @@
     class httpsconnection(BetterHTTPS):
         response_class = keepalive.HTTPResponse
         # must be able to send big bundle as stream.
-        send = _gen_sendfile(BetterHTTPS)
+        send = _gen_sendfile(BetterHTTPS.send)
         getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection)
 
         def connect(self):


More information about the Mercurial-devel mailing list