[Python-checkins] r70635 - in python/branches/py3k/Lib/http: client.py server.py

jeremy.hylton python-checkins at python.org
Fri Mar 27 19:31:37 CET 2009


Author: jeremy.hylton
Date: Fri Mar 27 19:31:36 2009
New Revision: 70635
Log:
Fix compatibility issue with HTTPMessage class.
The server needs to use MessageClass to parse.
Modified:
 python/branches/py3k/Lib/http/client.py
 python/branches/py3k/Lib/http/server.py
Modified: python/branches/py3k/Lib/http/client.py
==============================================================================
--- python/branches/py3k/Lib/http/client.py	(original)
+++ python/branches/py3k/Lib/http/client.py	Fri Mar 27 19:31:36 2009
@@ -213,7 +213,6 @@
 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 @@
 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 @@
 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):
 
Modified: python/branches/py3k/Lib/http/server.py
==============================================================================
--- python/branches/py3k/Lib/http/server.py	(original)
+++ python/branches/py3k/Lib/http/server.py	Fri Mar 27 19:31:36 2009
@@ -313,7 +313,8 @@
 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':


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /