comparison mercurial/httprepo.py @ 4132:0d94e4a3ddb4

Close keepalive connections to fix server traceback
author Andrei Vermel <avermel@mail.ru>
date Mon, 19 Feb 2007 12:38:58 +0300
parents d8b3edf88af0
children 9dc64c8414ca fffacca46f09
comparison
equal deleted inserted replaced
4131:1ca664c964e0 4132:0d94e4a3ddb4
125 125
126 class httprepository(remoterepository): 126 class httprepository(remoterepository):
127 def __init__(self, ui, path): 127 def __init__(self, ui, path):
128 self.path = path 128 self.path = path
129 self.caps = None 129 self.caps = None
130 self.handler = None
130 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 131 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
131 if query or frag: 132 if query or frag:
132 raise util.Abort(_('unsupported URL component: "%s"') % 133 raise util.Abort(_('unsupported URL component: "%s"') %
133 (query or frag)) 134 (query or frag))
134 if not urlpath: urlpath = '/' 135 if not urlpath: urlpath = '/'
139 urlpath, '', '')) 140 urlpath, '', ''))
140 self.ui = ui 141 self.ui = ui
141 142
142 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') 143 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
143 # XXX proxyauthinfo = None 144 # XXX proxyauthinfo = None
144 handlers = [httphandler()] 145 self.handler = httphandler()
146 handlers = [self.handler]
145 147
146 if proxyurl: 148 if proxyurl:
147 # proxy can be proper url or host[:port] 149 # proxy can be proper url or host[:port]
148 if not (proxyurl.startswith('http:') or 150 if not (proxyurl.startswith('http:') or
149 proxyurl.startswith('https:')): 151 proxyurl.startswith('https:')):
197 opener = urllib2.build_opener(*handlers) 199 opener = urllib2.build_opener(*handlers)
198 200
199 # 1.0 here is the _protocol_ version 201 # 1.0 here is the _protocol_ version
200 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] 202 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
201 urllib2.install_opener(opener) 203 urllib2.install_opener(opener)
204
205 def __del__(self):
206 if self.handler:
207 self.handler.close_all()
208 self.handler = None
202 209
203 def url(self): 210 def url(self):
204 return self.path 211 return self.path
205 212
206 # look up capabilities only when needed 213 # look up capabilities only when needed