101 |
101 |
102 class httpconnection(keepalive.HTTPConnection): |
102 class httpconnection(keepalive.HTTPConnection): |
103 # must be able to send big bundle as stream. |
103 # must be able to send big bundle as stream. |
104 send = _gen_sendfile(keepalive.HTTPConnection) |
104 send = _gen_sendfile(keepalive.HTTPConnection) |
105 |
105 |
106 class basehttphandler(keepalive.HTTPHandler): |
106 class httphandler(keepalive.HTTPHandler): |
107 def http_open(self, req): |
107 def http_open(self, req): |
108 return self.do_open(httpconnection, req) |
108 return self.do_open(httpconnection, req) |
109 |
109 |
110 def __del__(self): |
110 def __del__(self): |
111 self.close_all() |
111 self.close_all() |
115 class httpsconnection(httplib.HTTPSConnection): |
115 class httpsconnection(httplib.HTTPSConnection): |
116 response_class = keepalive.HTTPResponse |
116 response_class = keepalive.HTTPResponse |
117 # must be able to send big bundle as stream. |
117 # must be able to send big bundle as stream. |
118 send = _gen_sendfile(httplib.HTTPSConnection) |
118 send = _gen_sendfile(httplib.HTTPSConnection) |
119 |
119 |
120 class httphandler(basehttphandler, urllib2.HTTPSHandler): |
120 class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): |
121 def https_open(self, req): |
121 def https_open(self, req): |
122 return self.do_open(httpsconnection, req) |
122 return self.do_open(httpsconnection, req) |
123 else: |
|
124 class httphandler(basehttphandler): |
|
125 pass |
|
126 |
123 |
127 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if |
124 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if |
128 # it doesn't know about the auth type requested. This can happen if |
125 # it doesn't know about the auth type requested. This can happen if |
129 # somebody is using BasicAuth and types a bad password. |
126 # somebody is using BasicAuth and types a bad password. |
130 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): |
127 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): |
205 self.ui.debug(_('using %s\n') % self._url) |
202 self.ui.debug(_('using %s\n') % self._url) |
206 |
203 |
207 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') |
204 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') |
208 # XXX proxyauthinfo = None |
205 # XXX proxyauthinfo = None |
209 handlers = [httphandler()] |
206 handlers = [httphandler()] |
|
207 if has_https: |
|
208 handlers.append(httpshandler()) |
210 |
209 |
211 if proxyurl: |
210 if proxyurl: |
212 # proxy can be proper url or host[:port] |
211 # proxy can be proper url or host[:port] |
213 if not (proxyurl.startswith('http:') or |
212 if not (proxyurl.startswith('http:') or |
214 proxyurl.startswith('https:')): |
213 proxyurl.startswith('https:')): |