248
248
def _http_start(self):
250
250
httpd = self._get_httpd()
251
host, port = httpd.socket.getsockname()
252
self._http_base_url = '%s://localhost:%s/' % (self._url_protocol, port)
251
host, self.port = httpd.socket.getsockname()
252
self._http_base_url = '%s://localhost:%s/' % (self._url_protocol,
253
254
self._http_starting.release()
254
255
httpd.socket.settimeout(0.1)
287
288
self._http_base_url = None
288
289
self._http_thread = threading.Thread(target=self._http_start)
289
290
self._http_thread.setDaemon(True)
290
self._http_thread.start()
291
# Ensure we are not influenced by the environment
291
292
self._http_proxy = os.environ.get("http_proxy")
292
293
if self._http_proxy is not None:
293
294
del os.environ["http_proxy"]
295
self._no_proxy = os.environ.get("no_proxy")
296
if self._no_proxy is not None:
297
del os.environ["no_proxy"]
298
self._http_thread.start()
296
301
def tearDown(self):
297
302
"""See bzrlib.transport.Server.tearDown."""
298
303
self._http_running = False
299
304
self._http_thread.join()
300
if self._http_proxy is not None:
305
if self._http_proxy is None:
306
if os.environ.get("http_proxy") is not None:
307
del os.environ["http_proxy"]
302
309
os.environ["http_proxy"] = self._http_proxy
310
if self._no_proxy is None:
311
if os.environ.get("no_proxy") is not None:
312
del os.environ["no_proxy"]
314
os.environ["no_proxy"] = self.no_proxy
304
316
def get_url(self):
305
317
"""See bzrlib.transport.Server.get_url."""