~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HttpServer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-13 16:23:52 UTC
  • mfrom: (2182.1.1 Aaron's integration)
  • Revision ID: pqm@pqm.ubuntu.com-20061213162352-0de9ae3d8d38f95d
Respect proxy environment settings (Vincent Ladeuil, #74759)

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
    def _http_start(self):
253
253
        httpd = None
254
254
        httpd = self._get_httpd()
255
 
        host, port = httpd.socket.getsockname()
256
 
        self._http_base_url = '%s://localhost:%s/' % (self._url_protocol, port)
 
255
        host, self.port = httpd.socket.getsockname()
 
256
        self._http_base_url = '%s://localhost:%s/' % (self._url_protocol,
 
257
                                                      self.port)
257
258
        self._http_starting.release()
258
259
        httpd.socket.settimeout(0.1)
259
260
 
273
274
        else:
274
275
            remote_path = '/'.join(path_parts)
275
276
 
276
 
        self._http_starting.acquire()
277
 
        self._http_starting.release()
278
277
        return self._http_base_url + remote_path
279
278
 
280
279
    def log(self, format, *args):
292
291
        self._http_thread = threading.Thread(target=self._http_start)
293
292
        self._http_thread.setDaemon(True)
294
293
        self._http_thread.start()
295
 
        self._http_proxy = os.environ.get("http_proxy")
296
 
        if self._http_proxy is not None:
297
 
            del os.environ["http_proxy"]
 
294
        # Wait for the server thread to start (i.e release the lock)
 
295
        self._http_starting.acquire()
 
296
        self._http_starting.release()
298
297
        self.logs = []
299
298
 
300
299
    def tearDown(self):
301
300
        """See bzrlib.transport.Server.tearDown."""
302
301
        self._http_running = False
303
302
        self._http_thread.join()
304
 
        if self._http_proxy is not None:
305
 
            import os
306
 
            os.environ["http_proxy"] = self._http_proxy
307
303
 
308
304
    def get_url(self):
309
305
        """See bzrlib.transport.Server.get_url."""