SF patch #405845 by Martin von Löwis

Fixes SF bug #405427.
If an http response has a bogus return code, e.g. 400.100, raise
BadStatusLine.
This commit is contained in:
Jeremy Hylton 2001-04-13 14:57:08 +00:00
parent 3bee2f6011
commit 23d4047790
1 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,13 @@ class HTTPResponse:
self.close()
raise BadStatusLine(line)
self.status = status = int(status)
# The status code is a three-digit number
try:
self.status = status = int(status)
if status < 100 or status > 999:
raise BadStatusLine(line)
except ValueError:
raise BadStatusLine(line)
self.reason = reason.strip()
if version == 'HTTP/1.0':