mercurial/url.py
changeset 40044 6509fcec830c
parent 40035 393e44324037
child 41469 bc776c31c093
equal deleted inserted replaced
40043:208303a8172c 40044:6509fcec830c
   315             if self._tunnel_host:
   315             if self._tunnel_host:
   316                 self._tunnel()
   316                 self._tunnel()
   317 
   317 
   318 class logginghttphandler(httphandler):
   318 class logginghttphandler(httphandler):
   319     """HTTP handler that logs socket I/O."""
   319     """HTTP handler that logs socket I/O."""
   320     def __init__(self, logfh, name, observeropts):
   320     def __init__(self, logfh, name, observeropts, timeout=None):
   321         super(logginghttphandler, self).__init__()
   321         super(logginghttphandler, self).__init__(timeout=timeout)
   322 
   322 
   323         self._logfh = logfh
   323         self._logfh = logfh
   324         self._logname = name
   324         self._logname = name
   325         self._observeropts = observeropts
   325         self._observeropts = observeropts
   326 
   326 
   363                 self.sock, self.key_file, self.cert_file, ui=self.ui,
   363                 self.sock, self.key_file, self.cert_file, ui=self.ui,
   364                 serverhostname=host)
   364                 serverhostname=host)
   365             sslutil.validatesocket(self.sock)
   365             sslutil.validatesocket(self.sock)
   366 
   366 
   367     class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler):
   367     class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler):
   368         def __init__(self, ui):
   368         def __init__(self, ui, timeout=None):
   369             keepalive.KeepAliveHandler.__init__(self)
   369             keepalive.KeepAliveHandler.__init__(self, timeout=timeout)
   370             urlreq.httpshandler.__init__(self)
   370             urlreq.httpshandler.__init__(self)
   371             self.ui = ui
   371             self.ui = ui
   372             self.pwmgr = passwordmgr(self.ui,
   372             self.pwmgr = passwordmgr(self.ui,
   373                                      self.ui.httppasswordmgrdb)
   373                                      self.ui.httppasswordmgrdb)
   374 
   374 
   523     ``util.socketobserver`` instance.
   523     ``util.socketobserver`` instance.
   524 
   524 
   525     ``sendaccept`` allows controlling whether the ``Accept`` request header
   525     ``sendaccept`` allows controlling whether the ``Accept`` request header
   526     is sent. The header is sent by default.
   526     is sent. The header is sent by default.
   527     '''
   527     '''
       
   528     timeout = ui.configwith(float, 'http', 'timeout')
   528     handlers = []
   529     handlers = []
   529 
   530 
   530     if loggingfh:
   531     if loggingfh:
   531         handlers.append(logginghttphandler(loggingfh, loggingname,
   532         handlers.append(logginghttphandler(loggingfh, loggingname,
   532                                            loggingopts or {}))
   533                                            loggingopts or {}, timeout=timeout))
   533         # We don't yet support HTTPS when logging I/O. If we attempt to open
   534         # We don't yet support HTTPS when logging I/O. If we attempt to open
   534         # an HTTPS URL, we'll likely fail due to unknown protocol.
   535         # an HTTPS URL, we'll likely fail due to unknown protocol.
   535 
   536 
   536     else:
   537     else:
   537         handlers.append(httphandler())
   538         handlers.append(httphandler(timeout=timeout))
   538         if has_https:
   539         if has_https:
   539             handlers.append(httpshandler(ui))
   540             handlers.append(httpshandler(ui, timeout=timeout))
   540 
   541 
   541     handlers.append(proxyhandler(ui))
   542     handlers.append(proxyhandler(ui))
   542 
   543 
   543     passmgr = passwordmgr(ui, ui.httppasswordmgrdb)
   544     passmgr = passwordmgr(ui, ui.httppasswordmgrdb)
   544     if authinfo is not None:
   545     if authinfo is not None: