Fixes by John Reese and Jacques Frechet that make test_xmlrpc pass.
(Note that test_xmlrpc isn't touched by the fixes!) There were two separate issues; (a) BaseHTTPServer was using a TextIOWrapper which was swallowing some of the POST body; (b) the getheaders() API was changed but (due to integration of 2.6 code) the code wasn't modified.
This commit is contained in:
parent
2523621693
commit
cfe02a498b
|
@ -278,14 +278,21 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
||||||
return False
|
return False
|
||||||
self.command, self.path, self.request_version = command, path, version
|
self.command, self.path, self.request_version = command, path, version
|
||||||
|
|
||||||
# Examine the headers and look for a Connection directive
|
# Examine the headers and look for a Connection directive.
|
||||||
# MessageClass == rfc822 expects ascii, so use a text wrapper.
|
|
||||||
text = io.TextIOWrapper(self.rfile)
|
# MessageClass (rfc822) wants to see strings rather than bytes.
|
||||||
self.headers = self.MessageClass(text, 0)
|
# But a TextIOWrapper around self.rfile would buffer too many bytes
|
||||||
# The text wrapper does buffering (as does self.rfile). We
|
# from the stream, bytes which we later need to read as bytes.
|
||||||
# don't want to leave any data in the buffer of the text
|
# So we read the correct bytes here, as bytes, then use StringIO
|
||||||
# wrapper.
|
# to make them look like strings for MessageClass to parse.
|
||||||
assert not text.buffer.peek()
|
headers = []
|
||||||
|
while True:
|
||||||
|
line = self.rfile.readline()
|
||||||
|
headers.append(line)
|
||||||
|
if line in (b'\r\n', b'\n', b''):
|
||||||
|
break
|
||||||
|
hfile = io.StringIO(b''.join(headers).decode('iso-8859-1'))
|
||||||
|
self.headers = self.MessageClass(hfile)
|
||||||
|
|
||||||
conntype = self.headers.get('Connection', "")
|
conntype = self.headers.get('Connection', "")
|
||||||
if conntype.lower() == 'close':
|
if conntype.lower() == 'close':
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ class Transport:
|
||||||
raise ProtocolError(
|
raise ProtocolError(
|
||||||
host + handler,
|
host + handler,
|
||||||
resp.status, resp.reason,
|
resp.status, resp.reason,
|
||||||
resp.getheaders()
|
dict(resp.getheaders())
|
||||||
)
|
)
|
||||||
|
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
Loading…
Reference in New Issue