MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_http_doubleslash

Method test_http_doubleslash

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

Source from the content-addressed store, hash-verified

1108 self.assertEqual(h._debuglevel, 4)
1109
1110 def test_http_doubleslash(self):
1111 # Checks the presence of any unnecessary double slash in url does not
1112 # break anything. Previously, a double slash directly after the host
1113 # could cause incorrect parsing.
1114 h = urllib.request.AbstractHTTPHandler()
1115 h.parent = MockOpener()
1116
1117 data = b""
1118 ds_urls = [
1119 "http://example.com/foo/bar/baz.html",
1120 "http://example.com//foo/bar/baz.html",
1121 "http://example.com/foo//bar/baz.html",
1122 "http://example.com/foo/bar//baz.html"
1123 ]
1124
1125 for ds_url in ds_urls:
1126 ds_req = Request(ds_url, data)
1127
1128 # Check whether host is determined correctly if there is no proxy
1129 np_ds_req = h.do_request_(ds_req)
1130 self.assertEqual(np_ds_req.unredirected_hdrs["Host"], "example.com")
1131
1132 # Check whether host is determined correctly if there is a proxy
1133 ds_req.set_proxy("someproxy:3128", None)
1134 p_ds_req = h.do_request_(ds_req)
1135 self.assertEqual(p_ds_req.unredirected_hdrs["Host"], "example.com")
1136
1137 def test_full_url_setter(self):
1138 # 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