diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/http/cookiejar.py | 2 | ||||
-rw-r--r-- | Lib/logging/handlers.py | 4 | ||||
-rw-r--r-- | Lib/urllib/request.py | 21 |
3 files changed, 14 insertions, 13 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py index e9b83ea..afd5f20 100644 --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1305,7 +1305,7 @@ class CookieJar: return attrs def add_cookie_header(self, request): - """Add correct Cookie: header to request (urllib2.Request object). + """Add correct Cookie: header to request (urllib.request.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 29c398d..1e69120 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1002,11 +1002,11 @@ class HTTPHandler(logging.Handler): Send the record to the Web server as an URL-encoded dictionary """ try: - import http.client, urllib + import http.client, urllib.parse host = self.host h = http.client.HTTP(host) url = self.url - data = urllib.urlencode(self.mapLogRecord(record)) + data = urllib.parse.urlencode(self.mapLogRecord(record)) if self.method == "GET": if (url.find('?') >= 0): sep = '&' diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index da13147..9f5e607 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -47,24 +47,25 @@ _call_chain conventions Example usage: -import urllib2 +import urllib.request # set up authentication info -authinfo = urllib2.HTTPBasicAuthHandler() +authinfo = urllib.request.HTTPBasicAuthHandler() authinfo.add_password(realm='PDQ Application', uri='https://mahler:8092/site-updates.py', user='klem', passwd='geheim$parole') -proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"}) +proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"}) # build a new opener that adds authentication and caching FTP handlers -opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler) +opener = urllib.request.build_opener(proxy_support, authinfo, + urllib.request.CacheFTPHandler) # install it -urllib2.install_opener(opener) +urllib.request.install_opener(opener) -f = urllib2.urlopen('http://www.python.org/') +f = urllib.request.urlopen('http://www.python.org/') """ # XXX issues: @@ -502,7 +503,7 @@ class HTTPRedirectHandler(BaseHandler): # Strictly (according to RFC 2616), 301 or 302 in response to # a POST MUST NOT cause a redirection without confirmation - # from the user (of urllib2, in this case). In practice, + # from the user (of urllib.request, in this case). In practice, # essentially all clients do redirect in this case, so we do # the same. # be conciliant with URIs containing a space @@ -655,7 +656,7 @@ class ProxyHandler(BaseHandler): if proxy_type is None: proxy_type = orig_type if user and password: - user_pass = '%s:%s' % (unquote(user), + user_pass = '%s:%s' % (urllib.parse.unquote(user), urllib.parse.unquote(password)) creds = base64.b64encode(user_pass.encode()).decode("ascii") req.add_header('Proxy-authorization', 'Basic ' + creds) @@ -808,7 +809,7 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): def http_error_407(self, req, fp, code, msg, headers): # http_error_auth_reqed requires that there is no userinfo component in - # authority. Assume there isn't one, since urllib2 does not (and + # authority. Assume there isn't one, since urllib.request does not (and # should not, RFC 3986 s. 3.2.1) support requests for URLs containing # userinfo. authority = req.get_host() @@ -1194,7 +1195,7 @@ class FileHandler(BaseHandler): return urllib.response.addinfourl(open(localfile, 'rb'), headers, 'file:'+file) except OSError as msg: - # urllib2 users shouldn't expect OSErrors coming from urlopen() + # users shouldn't expect OSErrors coming from urlopen() raise urllib.error.URLError(msg) raise urllib.error.URLError('file not on local host') |