MCPcopy Index your code
hub / github.com/python/cpython / test_http_doubleslash

Method test_http_doubleslash

Lib/test/test_urllib2.py:1127–1152  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1125 self.assertEqual(h._debuglevel, 4)
1126
1127 def test_http_doubleslash(self):
1128 # Checks the presence of any unnecessary double slash in url does not
1129 # break anything. Previously, a double slash directly after the host
1130 # could cause incorrect parsing.
1131 h = urllib.request.AbstractHTTPHandler()
1132 h.parent = MockOpener()
1133
1134 data = b""
1135 ds_urls = [
1136 "http://example.com/foo/bar/baz.html",
1137 "http://example.com//foo/bar/baz.html",
1138 "http://example.com/foo//bar/baz.html",
1139 "http://example.com/foo/bar//baz.html"
1140 ]
1141
1142 for ds_url in ds_urls:
1143 ds_req = Request(ds_url, data)
1144
1145 # Check whether host is determined correctly if there is no proxy
1146 np_ds_req = h.do_request_(ds_req)
1147 self.assertEqual(np_ds_req.unredirected_hdrs["Host"], "example.com")
1148
1149 # Check whether host is determined correctly if there is a proxy
1150 ds_req.set_proxy("someproxy:3128", None)
1151 p_ds_req = h.do_request_(ds_req)
1152 self.assertEqual(p_ds_req.unredirected_hdrs["Host"], "example.com")
1153
1154 def test_full_url_setter(self):
1155 # Checks to ensure that components are set correctly after setting the

Callers

nothing calls this directly

Calls 5

do_request_Method · 0.95
set_proxyMethod · 0.95
RequestClass · 0.90
MockOpenerClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected