~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

  • Committer: Vincent Ladeuil
  • Date: 2009-01-08 16:57:10 UTC
  • mfrom: (2929.3.27 https)
  • mto: This revision was merged to the branch mainline in revision 3929.
  • Revision ID: v.ladeuil+lp@free.fr-20090108165710-d49d4uuq3emdr749
Add native ssl support for python-2.6, starting with an https test server

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from bzrlib.transport import local
35
35
 
36
36
 
37
 
class WebserverNotAvailable(Exception):
38
 
    pass
39
 
 
40
 
 
41
37
class BadWebserverPath(ValueError):
42
38
    def __str__(self):
43
39
        return 'path %s is not in %s' % self.args
181
177
            content_length += self._header_line_length(
182
178
                'Content-Range', 'bytes %d-%d/%d' % (start, end, file_size))
183
179
            content_length += len('\r\n') # end headers
184
 
            content_length += end - start # + 1
 
180
            content_length += end - start + 1
185
181
        content_length += len(boundary_line)
186
182
        self.send_header('Content-length', content_length)
187
183
        self.end_headers()
424
420
        # Allows tests to verify number of GET requests issued
425
421
        self.GET_request_nb = 0
426
422
 
 
423
    def create_httpd(self, serv_cls, rhandler_cls):
 
424
        return serv_cls((self.host, self.port), self.request_handler, self)
 
425
 
427
426
    def __repr__(self):
428
427
        return "%s(%s:%s)" % \
429
428
            (self.__class__.__name__, self.host, self.port)
445
444
            if serv_cls is None:
446
445
                raise httplib.UnknownProtocol(proto_vers)
447
446
            else:
448
 
                self._httpd = serv_cls((self.host, self.port), rhandler, self)
 
447
                self._httpd = self.create_httpd(serv_cls, rhandler)
449
448
            host, self.port = self._httpd.socket.getsockname()
450
449
        return self._httpd
451
450