blob: d39e85f4153e7ca8bd2accc35280fe62ad92ed26 [file] [log] [blame]
Tim Petersd48004f2001-09-25 19:29:35 +00001from test_support import verify,verbose
Jeremy Hylton79fa2b62001-04-13 14:57:44 +00002import httplib
3import StringIO
4
5class FakeSocket:
6 def __init__(self, text):
7 self.text = text
8
9 def makefile(self, mode, bufsize=None):
10 if mode != 'r' and mode != 'rb':
11 raise UnimplementedFileMode()
12 return StringIO.StringIO(self.text)
13
14# Test HTTP status lines
15
16body = "HTTP/1.1 200 Ok\r\n\r\nText"
17sock = FakeSocket(body)
18resp = httplib.HTTPResponse(sock,1)
19resp.begin()
20print resp.read()
21resp.close()
22
23body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
24sock = FakeSocket(body)
25resp = httplib.HTTPResponse(sock,1)
26try:
27 resp.begin()
28except httplib.BadStatusLine:
29 print "BadStatusLine raised as expected"
30else:
31 print "Expect BadStatusLine"