summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2009-03-27 18:31:36 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2009-03-27 18:31:36 (GMT)
commit98eb6c283881168adbedf37bb34300c39954397a (patch)
treefcf13a785b31d4a0bc7e05d8117fab7bc64de2fe /Lib/http
parent914ab45d0a976ba43143db86c3e560efed52e0ff (diff)
downloadcpython-98eb6c283881168adbedf37bb34300c39954397a.zip
cpython-98eb6c283881168adbedf37bb34300c39954397a.tar.gz
cpython-98eb6c283881168adbedf37bb34300c39954397a.tar.bz2
Fix compatibility issue with HTTPMessage class.
The server needs to use MessageClass to parse.
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/client.py5
-rw-r--r--Lib/http/server.py3
2 files changed, 4 insertions, 4 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 1fe010c..5e091b8 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -213,7 +213,6 @@ class HTTPMessage(email.message.Message):
occurrences are returned. Case is not important in the header name.
"""
- # XXX: copied from rfc822.Message for compatibility
name = name.lower() + ':'
n = len(name)
lst = []
@@ -227,7 +226,7 @@ class HTTPMessage(email.message.Message):
lst.append(line)
return lst
-def parse_headers(fp):
+def parse_headers(fp, _class=HTTPMessage):
"""Parses only RFC2822 headers from a file pointer.
email Parser wants to see strings rather than bytes.
@@ -245,7 +244,7 @@ def parse_headers(fp):
break
hstring = b''.join(headers).decode('iso-8859-1')
- return email.parser.Parser(_class=HTTPMessage).parsestr(hstring)
+ return email.parser.Parser(_class=_class).parsestr(hstring)
class HTTPResponse(io.RawIOBase):
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 897908e..31153f4 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -313,7 +313,8 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
self.command, self.path, self.request_version = command, path, version
# Examine the headers and look for a Connection directive.
- self.headers = http.client.parse_headers(self.rfile)
+ self.headers = http.client.parse_headers(self.rfile,
+ _class=self.MessageClass)
conntype = self.headers.get('Connection', "")
if conntype.lower() == 'close':