summaryrefslogtreecommitdiffstats
path: root/Lib/http/cookiejar.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2008-06-18 20:49:58 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2008-06-18 20:49:58 (GMT)
commit1afc1696167547a5fa101c53e5a3ab4717f8852c (patch)
treee989e72e71530d892214562785df7e11f84c1111 /Lib/http/cookiejar.py
parenta656d2cd8984f1ecb5a7e2cd09a18f72452f2b78 (diff)
downloadcpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.zip
cpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.tar.gz
cpython-1afc1696167547a5fa101c53e5a3ab4717f8852c.tar.bz2
Make a new urllib package .
It consists of code from urllib, urllib2, urlparse, and robotparser. The old modules have all been removed. The new package has five submodules: urllib.parse, urllib.request, urllib.response, urllib.error, and urllib.robotparser. The urllib.request.urlopen() function uses the url opener from urllib2. Note that the unittests have not been renamed for the beta, but they will be renamed in the future. Joint work with Senthil Kumaran.
Diffstat (limited to 'Lib/http/cookiejar.py')
-rw-r--r--Lib/http/cookiejar.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index 99be888..e9b83ea 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -28,7 +28,10 @@ http://wwwsearch.sf.net/):
__all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy',
'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar']
-import re, urlparse, copy, time, urllib
+import copy
+import re
+import time
+import urllib.parse, urllib.request
try:
import threading as _threading
except ImportError:
@@ -580,7 +583,7 @@ def request_host(request):
"""
url = request.get_full_url()
- host = urlparse.urlparse(url)[1]
+ host = urllib.parse.urlparse(url)[1]
if host == "":
host = request.get_header("Host", "")
@@ -602,13 +605,11 @@ def eff_request_host(request):
def request_path(request):
"""request-URI, as defined by RFC 2965."""
url = request.get_full_url()
- #scheme, netloc, path, parameters, query, frag = urlparse.urlparse(url)
- #req_path = escape_path("".join(urlparse.urlparse(url)[2:]))
- path, parameters, query, frag = urlparse.urlparse(url)[2:]
+ path, parameters, query, frag = urllib.parse.urlparse(url)[2:]
if parameters:
path = "%s;%s" % (path, parameters)
path = escape_path(path)
- req_path = urlparse.urlunparse(("", "", path, "", query, frag))
+ req_path = urllib.parse.urlunparse(("", "", path, "", query, frag))
if not req_path.startswith("/"):
# fix bad RFC 2396 absoluteURI
req_path = "/"+req_path
@@ -644,7 +645,7 @@ def escape_path(path):
# And here, kind of: draft-fielding-uri-rfc2396bis-03
# (And in draft IRI specification: draft-duerst-iri-05)
# (And here, for new URI schemes: RFC 2718)
- path = urllib.quote(path, HTTP_PATH_SAFE)
+ path = urllib.parse.quote(path, HTTP_PATH_SAFE)
path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
return path
@@ -1197,8 +1198,7 @@ class CookieJar:
"""Collection of HTTP cookies.
You may not need to know about this class: try
- urllib2.build_opener(HTTPCookieProcessor).open(url).
-
+ urllib.request.build_opener(HTTPCookieProcessor).open(url).
"""
non_word_re = re.compile(r"\W")