Mercurial > hg
comparison mercurial/httppeer.py @ 35697:5a7906ed78d4
httppeer: move url opening in its own method
This will help adding debugging logic to request opening when investigating
Mercurial performance.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 12 Jan 2018 10:14:20 +0000 |
parents | 98bc4c43f570 |
children | 0c4b23ccf1a5 |
comparison
equal
deleted
inserted
replaced
35696:925107e37619 | 35697:5a7906ed78d4 |
---|---|
158 urlopener = getattr(self, '_urlopener', None) | 158 urlopener = getattr(self, '_urlopener', None) |
159 if urlopener: | 159 if urlopener: |
160 for h in urlopener.handlers: | 160 for h in urlopener.handlers: |
161 h.close() | 161 h.close() |
162 getattr(h, "close_all", lambda: None)() | 162 getattr(h, "close_all", lambda: None)() |
163 | |
164 def _openurl(self, req): | |
165 return self._urlopener.open(req) | |
163 | 166 |
164 # Begin of _basepeer interface. | 167 # Begin of _basepeer interface. |
165 | 168 |
166 @util.propertycache | 169 @util.propertycache |
167 def ui(self): | 170 def ui(self): |
296 | 299 |
297 if data is not None: | 300 if data is not None: |
298 self.ui.debug("sending %s bytes\n" % size) | 301 self.ui.debug("sending %s bytes\n" % size) |
299 req.add_unredirected_header('Content-Length', '%d' % size) | 302 req.add_unredirected_header('Content-Length', '%d' % size) |
300 try: | 303 try: |
301 resp = self._urlopener.open(req) | 304 resp = self._openurl(req) |
302 except urlerr.httperror as inst: | 305 except urlerr.httperror as inst: |
303 if inst.code == 401: | 306 if inst.code == 401: |
304 raise error.Abort(_('authorization failed')) | 307 raise error.Abort(_('authorization failed')) |
305 raise | 308 raise |
306 except httplib.HTTPException as inst: | 309 except httplib.HTTPException as inst: |