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