Fix Issue6791 - Limit the HTTP header readline with _MAXLENGTH. Patch by Antoine Pitrou

This commit is contained in:
Senthil Kumaran 2010-12-18 16:55:23 +00:00
parent 32e1771daf
commit 5466bf1c94
4 changed files with 67 additions and 8 deletions

View file

@ -314,8 +314,12 @@ 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,
_class=self.MessageClass)
try:
self.headers = http.client.parse_headers(self.rfile,
_class=self.MessageClass)
except http.client.LineTooLong:
self.send_error(400, "Line too long")
return False
conntype = self.headers.get('Connection', "")
if conntype.lower() == 'close':