~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-24 14:57:25 UTC
  • mto: (3928.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3929.
  • Revision ID: v.ladeuil+lp@free.fr-20071124145725-vy1kdhey2jusaj04
Implement an https server passing the same tests than http. Except
for test_readv_with_adjust_for_latency of course (hi robert
;-). There is a nasty bug there already triggered in the #158972
days, but nastier this time.

* bzrlib/transport/http/_urllib2_wrappers.py:
(HTTPSConnection.connect_to_origin): Takes python2.6 ssl
implementation into account if available.

* bzrlib/tests/https_server.py:
(TestingHTTPSServer): Real implementation for https.
(HTTPSServer): Real implementation with test ssl files.

* bzrlib/tests/http_server.py:
(HttpServer.create_httpd): New method allowing daughter classes to
create specific servers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
                and e.args[0] in (errno.EPIPE, errno.ECONNRESET,
67
67
                                  errno.ECONNABORTED,)):
68
68
                self.close_connection = 1
69
 
                pass
70
69
            else:
71
70
                raise
72
71
 
301
300
        self.port = 0
302
301
        self._httpd = None
303
302
 
 
303
    def create_httpd(self):
 
304
        return TestingHTTPServer((self.host, self.port), self.request_handler,
 
305
                                 self)
 
306
 
304
307
    def _get_httpd(self):
305
308
        if self._httpd is None:
306
 
            self._httpd = TestingHTTPServer((self.host, self.port),
307
 
                                            self.request_handler,
308
 
                                            self)
 
309
            self._httpd = self.create_httpd()
309
310
            host, self.port = self._httpd.socket.getsockname()
310
311
        return self._httpd
311
312
 
312
313
    def _http_start(self):
313
314
        httpd = self._get_httpd()
314
315
        self._http_base_url = '%s://%s:%s/' % (self._url_protocol,
315
 
                                               self.host,
316
 
                                               self.port)
 
316
                                               self.host, self.port)
317
317
        self._http_starting.release()
318
318
 
319
319
        while self._http_running: