Skip to content

Commit

Permalink
Fix compatibility issue with HTTPMessage class.
Browse files Browse the repository at this point in the history
The server needs to use MessageClass to parse.
  • Loading branch information
jeremyhylton committed Mar 27, 2009
1 parent 914ab45 commit 98eb6c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Lib/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ def getallmatchingheaders(self, name):
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 = []
Expand All @@ -227,7 +226,7 @@ def getallmatchingheaders(self, name):
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.
Expand All @@ -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):

Expand Down
3 changes: 2 additions & 1 deletion Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def parse_request(self):
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':
Expand Down

0 comments on commit 98eb6c2

Please sign in to comment.