blob: aef65a68112e399a96a38ffedd54bb43e9e1d728 [file] [log] [blame]
Jeremy Hylton79fa2b62001-04-13 14:57:44 +00001from test.test_support import verify,verbose
2import 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"