220
220
# must do this otherwise urllib can't parse the urls properly :(
221
for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh']:
221
for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh', 'bzr+http']:
222
222
transport.register_urlparse_netloc_protocol(scheme)
1757
1757
super(SmartSSHTransport, self).__init__(url, medium=medium)
1760
class SmartHTTPTransport(SmartTransport):
1761
"""Just a way to connect between a bzr+http:// url and http://.
1763
This connection operates slightly differently than the SmartSSHTransport.
1764
It uses a plain http:// transport underneath, which defines what remote
1765
.bzr/smart URL we are connected to. From there, all paths that are sent are
1766
sent as relative paths, this way, the remote side can properly
1767
de-reference them, since it is likely doing rewrite rules to translate an
1768
HTTP path into a local path.
1771
def __init__(self, url, http_transport=None):
1772
assert url.startswith('bzr+http://')
1774
if http_transport is None:
1775
http_url = url[len('bzr+'):]
1776
self._http_transport = transport.get_transport(http_url)
1778
self._http_transport = http_transport
1779
http_medium = self._http_transport.get_smart_medium()
1780
super(SmartHTTPTransport, self).__init__(url, medium=http_medium)
1782
def _remote_path(self, relpath):
1783
"""After connecting HTTP Transport only deals in relative URLs."""
1789
def abspath(self, relpath):
1790
"""Return the full url to the given relative path.
1792
:param relpath: the relative path or path components
1793
:type relpath: str or list
1795
return self._unparse_url(self._combine_paths(self._path, relpath))
1797
def clone(self, relative_url):
1798
"""Make a new SmartHTTPTransport related to me.
1800
This is re-implemented rather than using the default
1801
SmartTransport.clone() because we must be careful about the underlying
1805
abs_url = self.abspath(relative_url)
1808
# By cloning the underlying http_transport, we are able to share the
1810
new_transport = self._http_transport.clone(relative_url)
1811
return SmartHTTPTransport(abs_url, http_transport=new_transport)
1760
1814
def get_test_permutations():
1761
1815
"""Return (transport, server) permutations for testing."""
1762
1816
### We may need a little more test framework support to construct an