486
487
def _remote_path(self, relpath):
487
488
"""After connecting HTTP Transport only deals in relative URLs."""
489
# Adjust the relpath based on which URL this smart transport is
491
base = self._http_transport.base
492
url = urlutils.join(self.base[len('bzr+'):], relpath)
493
url = urlutils.normalize_url(url)
494
return urlutils.relative_url(base, url)
493
496
def abspath(self, relpath):
494
497
"""Return the full url to the given relative path.
504
507
This is re-implemented rather than using the default
505
508
RemoteTransport.clone() because we must be careful about the underlying
511
Also, the cloned smart transport will POST to the same .bzr/smart
512
location as this transport (although obviously the relative paths in the
513
smart requests may be different). This is so that the server doesn't
514
have to handle .bzr/smart requests at arbitrary places inside .bzr
515
directories, just at the initial URL the user uses.
517
The exception is parent paths (i.e. relative_url of "..").
509
520
abs_url = self.abspath(relative_url)
511
522
abs_url = self.base
512
# By cloning the underlying http_transport, we are able to share the
514
new_transport = self._http_transport.clone(relative_url)
515
return RemoteHTTPTransport(abs_url, http_transport=new_transport)
523
# We either use the exact same http_transport (for child locations), or
524
# a clone of the underlying http_transport (for parent locations). This
525
# means we share the connection.
526
normalized_rel_url = urlutils.relative_url(self.base, abs_url)
527
if normalized_rel_url == ".." or normalized_rel_url.startswith("../"):
528
http_transport = self._http_transport.clone(normalized_rel_url)
530
http_transport = self._http_transport
531
return RemoteHTTPTransport(abs_url, http_transport=http_transport)
518
534
def get_test_permutations():