mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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.
This commit is contained in:
parent
1e600dc01f
commit
c295862ce0
4 changed files with 29 additions and 2 deletions
|
@ -848,6 +848,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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue