533
533
scenarios = vary_by_http_client_implementation()
535
535
def test_http_registered(self):
536
t = transport.get_transport_from_url(
537
'%s://foo.com/' % self._url_protocol)
536
t = transport.get_transport('%s://foo.com/' % self._url_protocol)
538
537
self.assertIsInstance(t, transport.Transport)
539
538
self.assertIsInstance(t, self._transport)
552
551
self.start_server(server)
553
552
url = server.get_url()
554
553
# FIXME: needs a cleanup -- vila 20100611
555
http_transport = transport.get_transport_from_url(url)
554
http_transport = transport.get_transport(url)
556
555
code, response = http_transport._post('abc def end-of-body')
558
557
server.received_bytes.startswith('POST /.bzr/smart HTTP/1.'))
1638
1637
def get_user_transport(self, user, password):
1639
t = transport.get_transport_from_url(
1640
self.get_user_url(user, password))
1638
t = transport.get_transport(self.get_user_url(user, password))
1643
1641
def test_no_user(self):
1917
1915
# The 'readv' command in the smart protocol both sends and receives
1918
1916
# bulk data, so we use that.
1919
1917
self.build_tree(['data-file'])
1920
http_transport = transport.get_transport_from_url(
1921
self.http_server.get_url())
1918
http_transport = transport.get_transport(self.http_server.get_url())
1922
1919
medium = http_transport.get_smart_medium()
1923
1920
# Since we provide the medium, the url below will be mostly ignored
1924
1921
# during the test, as long as the path is '/'.
1932
1929
post_body = 'hello\n'
1933
1930
expected_reply_body = 'ok\x012\n'
1935
http_transport = transport.get_transport_from_url(
1936
self.http_server.get_url())
1932
http_transport = transport.get_transport(self.http_server.get_url())
1937
1933
medium = http_transport.get_smart_medium()
1938
1934
response = medium.send_http_smart_request(post_body)
1939
1935
reply_body = response.read()
1997
1993
self.assertIsInstance(r, type(t))
1998
1994
# Both transports share the some connection
1999
1995
self.assertEqual(t._get_connection(), r._get_connection())
2000
self.assertEquals('http://www.example.com/foo/subdir/', r.base)
2002
1997
def test_redirected_to_self_with_slash(self):
2003
1998
t = self._transport('http://www.example.com/foo')
2014
2009
r = t._redirected_to('http://www.example.com/foo',
2015
2010
'http://foo.example.com/foo/subdir')
2016
2011
self.assertIsInstance(r, type(t))
2017
self.assertEquals('http://foo.example.com/foo/subdir/',
2020
2013
def test_redirected_to_same_host_sibling_protocol(self):
2021
2014
t = self._transport('http://www.example.com/foo')
2022
2015
r = t._redirected_to('http://www.example.com/foo',
2023
2016
'https://www.example.com/foo')
2024
2017
self.assertIsInstance(r, type(t))
2025
self.assertEquals('https://www.example.com/foo/',
2028
2019
def test_redirected_to_same_host_different_protocol(self):
2029
2020
t = self._transport('http://www.example.com/foo')
2030
2021
r = t._redirected_to('http://www.example.com/foo',
2031
2022
'ftp://www.example.com/foo')
2032
2023
self.assertNotEquals(type(r), type(t))
2033
self.assertEquals('ftp://www.example.com/foo/', r.external_url())
2035
def test_redirected_to_same_host_specific_implementation(self):
2036
t = self._transport('http://www.example.com/foo')
2037
r = t._redirected_to('http://www.example.com/foo',
2038
'https+urllib://www.example.com/foo')
2039
self.assertEquals('https://www.example.com/foo/', r.external_url())
2041
2025
def test_redirected_to_different_host_same_user(self):
2042
2026
t = self._transport('http://joe@www.example.com/foo')
2043
2027
r = t._redirected_to('http://www.example.com/foo',
2044
2028
'https://foo.example.com/foo')
2045
2029
self.assertIsInstance(r, type(t))
2046
self.assertEqual(t._parsed_url.user, r._parsed_url.user)
2047
self.assertEquals('https://joe@foo.example.com/foo/', r.external_url())
2030
self.assertEqual(t._user, r._user)
2050
2033
class PredefinedRequestHandler(http_server.TestingHTTPRequestHandler):