/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 breezy/tests/http_server.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
    def send_error(self, code, message=None):
103
103
        """Send and log an error reply.
104
104
 
105
 
        We redefine the python-provided version to be able to set a
 
105
        We redefine the python-provided version to be able to set a 
106
106
        ``Content-Length`` header as some http/1.1 clients complain otherwise
107
107
        (see bug #568421).
108
108
 
233
233
        boundary = '%d' % random.randint(0, 0x7FFFFFFF)
234
234
        self.send_header('Content-Type',
235
235
                         'multipart/byteranges; boundary=%s' % boundary)
236
 
        boundary_line = b'--%s\r\n' % boundary.encode('ascii')
 
236
        boundary_line = '--%s\r\n' % boundary
237
237
        # Calculate the Content-Length
238
238
        content_length = 0
239
239
        for (start, end) in ranges:
242
242
                'Content-type', 'application/octet-stream')
243
243
            content_length += self._header_line_length(
244
244
                'Content-Range', 'bytes %d-%d/%d' % (start, end, file_size))
245
 
            content_length += len('\r\n')  # end headers
 
245
            content_length += len('\r\n') # end headers
246
246
            content_length += end - start + 1
247
247
        content_length += len(boundary_line)
248
248
        self.send_header('Content-length', content_length)
341
341
        path = urlparse(path)[2]
342
342
        path = posixpath.normpath(urlutils.unquote(path))
343
343
        if sys.version_info[0] == 2:
344
 
            path = path.decode('utf-8')
 
344
             path = path.decode('utf-8')
345
345
        words = path.split('/')
346
346
        path = self._cwd
347
347
        for num, word in enumerate(w for w in words if w):
348
348
            if num == 0:
349
349
                drive, word = os.path.splitdrive(word)
350
350
            head, word = os.path.split(word)
351
 
            if word in (os.curdir, os.pardir):
352
 
                continue
 
351
            if word in (os.curdir, os.pardir): continue
353
352
            path = os.path.join(path, word)
354
353
        return path
355
354
 
382
381
    server, we need an independent connection for each of them. We achieve that
383
382
    by spawning a new thread for each connection.
384
383
    """
385
 
 
386
384
    def __init__(self, server_address, request_handler_class,
387
385
                 test_case_server):
388
386
        test_server.TestingThreadingTCPServer.__init__(self, server_address,
450
448
        path_parts = path.split(os.path.sep)
451
449
        if os.path.isabs(path):
452
450
            if path_parts[:len(self._local_path_parts)] != \
453
 
                    self._local_path_parts:
 
451
                   self._local_path_parts:
454
452
                raise BadWebserverPath(path, self.test_dir)
455
453
            remote_path = '/'.join(path_parts[len(self._local_path_parts):])
456
454
        else: