summaryrefslogtreecommitdiffstats
path: root/Lib/urllib2.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2003-06-17 21:52:34 (GMT)
committerBrett Cannon <bcannon@gmail.com>2003-06-17 21:52:34 (GMT)
commit783eaf4774006d8cb6362d4136c88e74b36a0b77 (patch)
treeda355a2a8c6a046a3f42616ae91c83e78607d6e4 /Lib/urllib2.py
parent5ecd6c4db2b9d4b2d536b0210ad5aaf23bfc4dee (diff)
downloadcpython-783eaf4774006d8cb6362d4136c88e74b36a0b77.zip
cpython-783eaf4774006d8cb6362d4136c88e74b36a0b77.tar.gz
cpython-783eaf4774006d8cb6362d4136c88e74b36a0b77.tar.bz2
Change all header strings to be as if they were capitalize()'ed. Also call
capitalize in AbstractHTTPHandler before inserting headers into HTTP instance. Closes bug #649742, again.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r--Lib/urllib2.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 5734be7..52fe62b 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -254,7 +254,7 @@ class Request:
class OpenerDirector:
def __init__(self):
server_version = "Python-urllib/%s" % __version__
- self.addheaders = [('User-Agent', server_version)]
+ self.addheaders = [('User-agent', server_version)]
# manage the individual handlers
self.handlers = []
self.handle_open = {}
@@ -507,7 +507,7 @@ class ProxyHandler(BaseHandler):
user, password = user_pass.split(':', 1)
user_pass = base64.encodestring('%s:%s' % (unquote(user),
unquote(password)))
- req.add_header('Proxy-Authorization', 'Basic ' + user_pass)
+ req.add_header('Proxy-authorization', 'Basic ' + user_pass)
host = unquote(host)
req.set_proxy(host, type)
if orig_type == type:
@@ -666,7 +666,7 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
- auth_header = 'Proxy-Authorization'
+ auth_header = 'Proxy-authorization'
def http_error_407(self, req, fp, code, msg, headers):
host = req.get_host()
@@ -818,10 +818,10 @@ class AbstractHTTPHandler(BaseHandler):
scheme, sel = splittype(req.get_selector())
sel_host, sel_path = splithost(sel)
h.putheader('Host', sel_host or host)
- for args in self.parent.addheaders:
- name, value = args
+ for name, value in self.parent.addheaders:
+ name = name.capitalize()
if name not in req.headers:
- h.putheader(*args)
+ h.putheader(name, value)
for k, v in req.headers.items():
h.putheader(k, v)
# httplib will attempt to connect() here. be prepared
@@ -943,7 +943,7 @@ class FileHandler(BaseHandler):
modified = rfc822.formatdate(stats.st_mtime)
mtype = mimetypes.guess_type(file)[0]
headers = mimetools.Message(StringIO(
- 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
+ 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
(mtype or 'text/plain', size, modified)))
if host:
host, port = splitport(host)
@@ -985,9 +985,9 @@ class FTPHandler(BaseHandler):
headers = ""
mtype = mimetypes.guess_type(req.get_full_url())[0]
if mtype:
- headers += "Content-Type: %s\n" % mtype
+ headers += "Content-type: %s\n" % mtype
if retrlen is not None and retrlen >= 0:
- headers += "Content-Length: %d\n" % retrlen
+ headers += "Content-length: %d\n" % retrlen
sf = StringIO(headers)
headers = mimetools.Message(sf)
return addinfourl(fp, headers, req.get_full_url())