~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-31 17:25:22 UTC
  • mfrom: (1948.3.11 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1978.
  • Revision ID: john@arbash-meinel.com-20060831172522-125e48c70371ad27
[merge] Vincent Ladeuil: Update http transport to allow writable http

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
            # TODO: Don't call this with an array - no magic interfaces
171
171
            relpath_parts = relpath[:]
172
172
        if len(relpath_parts) > 1:
 
173
            # TODO: Check that the "within branch" part of the
 
174
            # error messages below is relevant in all contexts
173
175
            if relpath_parts[0] == '':
174
176
                raise ValueError("path %r within branch %r seems to be absolute"
175
177
                                 % (relpath, self._path))
176
 
            if relpath_parts[-1] == '':
 
178
            # read only transports never manipulate directories
 
179
            if self.is_readonly() and relpath_parts[-1] == '':
177
180
                raise ValueError("path %r within branch %r seems to be a directory"
178
181
                                 % (relpath, self._path))
179
182
        basepath = self._path.split('/')
494
497
    # used to form the url that connects to this server
495
498
    _url_protocol = 'http'
496
499
 
 
500
    # Subclasses can provide a specific request handler
 
501
    def __init__(self, request_handler=TestingHTTPRequestHandler):
 
502
        Server.__init__(self)
 
503
        self.request_handler = request_handler
 
504
 
497
505
    def _http_start(self):
498
506
        httpd = None
499
507
        httpd = TestingHTTPServer(('localhost', 0),
500
 
                                  TestingHTTPRequestHandler,
 
508
                                  self.request_handler,
501
509
                                  self)
502
510
        host, port = httpd.socket.getsockname()
503
511
        self._http_base_url = '%s://localhost:%s/' % (self._url_protocol, port)
558
566
        
559
567
    def get_bogus_url(self):
560
568
        """See bzrlib.transport.Server.get_bogus_url."""
561
 
        # this is chosen to try to prevent trouble with proxies, wierd dns,
 
569
        # this is chosen to try to prevent trouble with proxies, weird dns,
562
570
        # etc
563
571
        return 'http://127.0.0.1:1/'
564
572