/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

merge bzr.dev r4042

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
141
137
            # common)
142
138
            self.send_response(301)
143
139
            self.send_header("Location", self.path + "/")
144
 
            # Indicates that the body is empty for HTTP/1.1 clients 
 
140
            # Indicates that the body is empty for HTTP/1.1 clients
145
141
            self.send_header('Content-Length', '0')
146
142
            self.end_headers()
147
143
            return None
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()
324
320
 
325
321
    def tearDown(self):
326
322
         """Called to clean-up the server.
327
 
 
 
323
 
328
324
         Since the server may be (surely is, even) in a blocking listen, we
329
325
         shutdown its socket before closing it.
330
326
         """
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
 
504
503
 
505
504
    def setUp(self, backing_transport_server=None):
506
505
        """See bzrlib.transport.Server.setUp.
507
 
        
 
506
 
508
507
        :param backing_transport_server: The transport that requests over this
509
508
            protocol should be forwarded to. Note that this is currently not
510
509
            supported for HTTP.