Fix issue14826 - make urllib.request.Request quoted url consistent with URLOpener open method.

Patch contributed by Stephen Thorne.
This commit is contained in:
Senthil Kumaran 2012-07-07 17:37:53 -07:00
parent 5356af8c48
commit 01fe5fa8ea
3 changed files with 14 additions and 2 deletions

View file

@ -110,7 +110,7 @@ except ImportError:
from StringIO import StringIO
from urllib import (unwrap, unquote, splittype, splithost, quote,
addinfourl, splitport, splittag,
addinfourl, splitport, splittag, toBytes,
splitattr, ftpwrapper, splituser, splitpasswd, splitvalue)
# support for FileHandler, proxies via environment variables
@ -196,7 +196,8 @@ class Request:
def __init__(self, url, data=None, headers={},
origin_req_host=None, unverifiable=False):
# unwrap('<URL:type://host/path>') --> 'type://host/path'
self.__original = unwrap(url)
self.__original = unwrap(toBytes(url))
self.__original = quote(self.__original, safe="%/:=&?~#+!$,;'@()*[]|")
self.__original, self.__fragment = splittag(self.__original)
self.type = None
# self.__r_type is what's left after doing the splittype