# HG changeset patch # User Mads Kiilerich # Date 1297826897 -3600 # Node ID 051f498628f7b965de9f3e6e60eddc862afed3a2 # Parent 1cc73868c740e0c7f0fc53062bea92aa09005342 url: refactor _gen_sendfile diff -r 1cc73868c740 -r 051f498628f7 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):