url: refactor _gen_sendfile
authorMads Kiilerich <mads@kiilerich.com>
Wed, 16 Feb 2011 04:28:17 +0100
changeset 13420 051f498628f7
parent 13419 1cc73868c740
child 13421 bd8bfa85d5a5
url: refactor _gen_sendfile
mercurial/url.py
--- a/mercurial/url.py	Wed Feb 16 04:28:17 2011 +0100
+++ b/mercurial/url.py	Wed Feb 16 04:28:17 2011 +0100
@@ -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):