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

Method test_request_host

Lib/test/test_http_cookiejar.py:843–857  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

841 self.assertEqual(request_port(req), DEFAULT_HTTP_PORT)
842
843 def test_request_host(self):
844 # this request is illegal (RFC2616, 14.2.3)
845 req = urllib.request.Request("http://1.1.1.1/",
846 headers={"Host": "www.acme.com:80"})
847 # libwww-perl wants this response, but that seems wrong (RFC 2616,
848 # section 5.2, point 1., and RFC 2965 section 1, paragraph 3)
849 #self.assertEqual(request_host(req), "www.acme.com")
850 self.assertEqual(request_host(req), "1.1.1.1")
851 req = urllib.request.Request("http://www.acme.com/",
852 headers={"Host": "irrelevant.com"})
853 self.assertEqual(request_host(req), "www.acme.com")
854 # port shouldn't be in request-host
855 req = urllib.request.Request("http://www.acme.com:2345/resource.html",
856 headers={"Host": "www.acme.com:5432"})
857 self.assertEqual(request_host(req), "www.acme.com")
858
859 def test_is_HDN(self):
860 self.assertTrue(is_HDN("foo.bar.com"))

Callers

nothing calls this directly

Calls 2

request_hostFunction · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected