diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-13 14:57:08 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-04-13 14:57:08 (GMT) |
commit | 23d40477909054d8c0e7459601093ba750b4ea8b (patch) | |
tree | c7b6571df7e67026c879e9916abdc171e673c67f | |
parent | 3bee2f60112f6552e5993d1735a464b358e6ab69 (diff) | |
download | cpython-23d40477909054d8c0e7459601093ba750b4ea8b.zip cpython-23d40477909054d8c0e7459601093ba750b4ea8b.tar.gz cpython-23d40477909054d8c0e7459601093ba750b4ea8b.tar.bz2 |
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.
-rw-r--r-- | Lib/httplib.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index 6c3b5e0..fb87099 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -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': |