(self)
| 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 |
nothing calls this directly
no test coverage detected