summaryrefslogtreecommitdiffstats
path: root/Lib/httplib.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-10-12 19:58:36 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-10-12 19:58:36 (GMT)
commit110941a4ba037a3cab0224370aed71c465a2f865 (patch)
tree00f3c1a70acdede0b9d45fe0514d3993450b8afd /Lib/httplib.py
parent2bf405ad559a346577cc6b922fd45377c935fafb (diff)
downloadcpython-110941a4ba037a3cab0224370aed71c465a2f865.zip
cpython-110941a4ba037a3cab0224370aed71c465a2f865.tar.gz
cpython-110941a4ba037a3cab0224370aed71c465a2f865.tar.bz2
If the status line is invalid, assume it is a pre-1.0 response. The
msg/headers are empty and the entire response is treated as the body.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 3856854..2688359 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -118,8 +118,9 @@ class HTTPResponse:
[version, status] = string.split(line, None, 1)
reason = ""
except ValueError:
- self.close()
- raise BadStatusLine(line)
+ version = "HTTP/0.9"
+ status = "200"
+ reason = ""
if version[:5] != 'HTTP/':
self.close()
raise BadStatusLine(line)
@@ -129,11 +130,17 @@ class HTTPResponse:
if version == 'HTTP/1.0':
self.version = 10
- elif version[:7] == 'HTTP/1.':
+ elif version.startswith('HTTP/1.'):
self.version = 11 # use HTTP/1.1 code for HTTP/1.x where x>=1
+ elif version == 'HTTP/0.9':
+ self.version = 9
else:
raise UnknownProtocol(version)
+ if self.version == 9:
+ self.msg = mimetools.Message(StringIO())
+ return
+
self.msg = mimetools.Message(self.fp, 0)
if self.debuglevel > 0:
for hdr in self.msg.headers: