summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-08-16 14:44:07 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-08-16 14:44:07 (GMT)
commiteb90b788f44fae967e969e967e2bd2276f3c6597 (patch)
tree032583c2acf53f760f58fec052cde55596c3a50d /Lib/test
parent5b02ef3e1b444372bda5b80d8646eb0afc00636d (diff)
downloadcpython-eb90b788f44fae967e969e967e2bd2276f3c6597.zip
cpython-eb90b788f44fae967e969e967e2bd2276f3c6597.tar.gz
cpython-eb90b788f44fae967e969e967e2bd2276f3c6597.tar.bz2
Issue #2776: fixed small issue when handling an URL with double slash
after a 302 response in the case of not going through a proxy.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_urllib2.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 1e93fdb..e28ee71 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -772,6 +772,32 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(req.unredirected_hdrs["Host"], "baz")
self.assertEqual(req.unredirected_hdrs["Spam"], "foo")
+ def test_http_doubleslash(self):
+ # Checks that the presence of an unnecessary double slash in a url doesn't break anything
+ # Previously, a double slash directly after the host could cause incorrect parsing of the url
+ h = urllib2.AbstractHTTPHandler()
+ o = h.parent = MockOpener()
+
+ data = ""
+ ds_urls = [
+ "http://example.com/foo/bar/baz.html",
+ "http://example.com//foo/bar/baz.html",
+ "http://example.com/foo//bar/baz.html",
+ "http://example.com/foo/bar//baz.html",
+ ]
+
+ for ds_url in ds_urls:
+ ds_req = Request(ds_url, data)
+
+ # Check whether host is determined correctly if there is no proxy
+ np_ds_req = h.do_request_(ds_req)
+ self.assertEqual(np_ds_req.unredirected_hdrs["Host"],"example.com")
+
+ # Check whether host is determined correctly if there is a proxy
+ ds_req.set_proxy("someproxy:3128",None)
+ p_ds_req = h.do_request_(ds_req)
+ self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com")
+
def test_errors(self):
h = urllib2.HTTPErrorProcessor()
o = h.parent = MockOpener()