##// END OF EJS Templates
httppeer: move error handling and response wrapping into sendrequest...
Gregory Szorc -
r37568:b5862ee0 default
parent child Browse files
Show More
@@ -284,11 +284,25 b' def sendrequest(ui, opener, req):'
284
284
285 start = util.timer()
285 start = util.timer()
286
286
287 try:
287 res = opener.open(req)
288 res = opener.open(req)
289 except urlerr.httperror as inst:
290 if inst.code == 401:
291 raise error.Abort(_('authorization failed'))
292 raise
293 except httplib.HTTPException as inst:
294 ui.debug('http error requesting %s\n' %
295 util.hidepassword(req.get_full_url()))
296 ui.traceback()
297 raise IOError(None, inst)
298 finally:
288 if ui.configbool('devel', 'debug.peer-request'):
299 if ui.configbool('devel', 'debug.peer-request'):
289 dbg(line % ' finished in %.4f seconds (%s)'
300 dbg(line % ' finished in %.4f seconds (%s)'
290 % (util.timer() - start, res.code))
301 % (util.timer() - start, res.code))
291
302
303 # Insert error handlers for common I/O failures.
304 _wraphttpresponse(res)
305
292 return res
306 return res
293
307
294 class httppeer(wireproto.wirepeer):
308 class httppeer(wireproto.wirepeer):
@@ -346,19 +360,7 b' class httppeer(wireproto.wirepeer):'
346 self._caps, self.capable,
360 self._caps, self.capable,
347 self._url, cmd, args)
361 self._url, cmd, args)
348
362
349 try:
350 resp = sendrequest(self.ui, self._urlopener, req)
363 resp = sendrequest(self.ui, self._urlopener, req)
351 except urlerr.httperror as inst:
352 if inst.code == 401:
353 raise error.Abort(_('authorization failed'))
354 raise
355 except httplib.HTTPException as inst:
356 self.ui.debug('http error while sending %s command\n' % cmd)
357 self.ui.traceback()
358 raise IOError(None, inst)
359
360 # Insert error handlers for common I/O failures.
361 _wraphttpresponse(resp)
362
364
363 # record the url we got redirected to
365 # record the url we got redirected to
364 resp_url = pycompat.bytesurl(resp.geturl())
366 resp_url = pycompat.bytesurl(resp.geturl())
General Comments 0
You need to be logged in to leave comments. Login now