mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Allow rfc822 to process headers from an incoming HTTP request.
This commit is contained in:
parent
4b878bd3d5
commit
7ffe2998cd
1 changed files with 8 additions and 1 deletions
|
@ -70,6 +70,7 @@ __version__ = "0.3"
|
||||||
|
|
||||||
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
|
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
|
||||||
|
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import socket # For gethostbyaddr()
|
import socket # For gethostbyaddr()
|
||||||
|
@ -278,7 +279,13 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
||||||
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
|
||||||
self.headers = self.MessageClass(self.rfile, 0)
|
# MessageClass == rfc822 expects ascii, so use a text wrapper.
|
||||||
|
text = io.TextIOWrapper(self.rfile)
|
||||||
|
self.headers = self.MessageClass(text, 0)
|
||||||
|
# The text wrapper does buffering (as does self.rfile). We
|
||||||
|
# don't want to leave any data in the buffer of the text
|
||||||
|
# wrapper.
|
||||||
|
assert not text.buffer.peek()
|
||||||
|
|
||||||
conntype = self.headers.get('Connection', "")
|
conntype = self.headers.get('Connection', "")
|
||||||
if conntype.lower() == 'close':
|
if conntype.lower() == 'close':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue