summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-11-22 04:53:57 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-11-22 04:53:57 (GMT)
commitd17ebdba4a4443a523c0344440d37d472ed82b5a (patch)
tree73014b8ca980538f33d2de4a6d4fc54909b15668 /Lib/test/test_urllib2.py
parentf30fd1078289dccc746d989264938ae23806ab38 (diff)
downloadcpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.zip
cpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.tar.gz
cpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.tar.bz2
Merged revisions 86676 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86676 | senthil.kumaran | 2010-11-22 12:48:26 +0800 (Mon, 22 Nov 2010) | 4 lines Fix Issue4493 - urllib2 adds '/' to the path component of url, when it does not starts with one. This behavior is exhibited by browser and other clients. ........
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 38cf607..94bbc00 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -849,6 +849,25 @@ class HandlerTests(unittest.TestCase):
p_ds_req = h.do_request_(ds_req)
self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com")
+ def test_fixpath_in_weirdurls(self):
+ # Issue4493: urllib2 to supply '/' when to urls where path does not
+ # start with'/'
+
+ h = urllib.request.AbstractHTTPHandler()
+ o = h.parent = MockOpener()
+
+ weird_url = 'http://www.python.org?getspam'
+ req = Request(weird_url)
+ newreq = h.do_request_(req)
+ self.assertEqual(newreq.host,'www.python.org')
+ self.assertEqual(newreq.selector,'/?getspam')
+
+ url_without_path = 'http://www.python.org'
+ req = Request(url_without_path)
+ newreq = h.do_request_(req)
+ self.assertEqual(newreq.host,'www.python.org')
+ self.assertEqual(newreq.selector,'')
+
def test_errors(self):
h = urllib.request.HTTPErrorProcessor()