/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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
            self.close_connection = 1
91
91
            if (len(e.args) == 0
92
92
                or e.args[0] not in (errno.EPIPE, errno.ECONNRESET,
93
 
                                     errno.ECONNABORTED, errno.EBADF)):
 
93
                                  errno.ECONNABORTED, errno.EBADF)):
94
94
                raise
95
95
 
96
96
    error_content_type = 'text/plain'
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): continue
 
351
            if word in (os.curdir, os.pardir):
 
352
                continue
352
353
            path = os.path.join(path, word)
353
354
        return path
354
355
 
381
382
    server, we need an independent connection for each of them. We achieve that
382
383
    by spawning a new thread for each connection.
383
384
    """
 
385
 
384
386
    def __init__(self, server_address, request_handler_class,
385
387
                 test_case_server):
386
388
        test_server.TestingThreadingTCPServer.__init__(self, server_address,
448
450
        path_parts = path.split(os.path.sep)
449
451
        if os.path.isabs(path):
450
452
            if path_parts[:len(self._local_path_parts)] != \
451
 
                   self._local_path_parts:
 
453
                    self._local_path_parts:
452
454
                raise BadWebserverPath(path, self.test_dir)
453
455
            remote_path = '/'.join(path_parts[len(self._local_path_parts):])
454
456
        else:
471
473
        # disk.
472
474
        if not (backing_transport_server is None
473
475
                or isinstance(backing_transport_server,
474
 
                              test_server.LocalURLServer)):
 
476
                           test_server.LocalURLServer)):
475
477
            raise AssertionError(
476
478
                "HTTPServer currently assumes local transport, got %s" %
477
479
                backing_transport_server)