1 from test
.test_support
import verify
,verbose
6 def __init__(self
, text
):
9 def makefile(self
, mode
, bufsize
=None):
10 if mode
!= 'r' and mode
!= 'rb':
11 raise httplib
.UnimplementedFileMode()
12 return StringIO
.StringIO(self
.text
)
14 # Test HTTP status lines
16 body
= "HTTP/1.1 200 Ok\r\n\r\nText"
17 sock
= FakeSocket(body
)
18 resp
= httplib
.HTTPResponse(sock
, 1)
23 body
= "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
24 sock
= FakeSocket(body
)
25 resp
= httplib
.HTTPResponse(sock
, 1)
28 except httplib
.BadStatusLine
:
29 print "BadStatusLine raised as expected"
31 print "Expect BadStatusLine"
33 # Check invalid host_port
35 for hp
in ("www.python.org:abc", "www.python.org:"):
38 except httplib
.InvalidURL
:
39 print "InvalidURL raised as expected"
41 print "Expect InvalidURL"
43 # test response with multiple message headers with the same field name.
44 text
= ('HTTP/1.1 200 OK\r\n'
45 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n'
46 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";'
50 hdr
= ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"'
52 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"')
54 r
= httplib
.HTTPResponse(s
, 1)
56 cookies
= r
.getheader("Set-Cookie")
58 raise AssertionError, "multiple headers not combined properly"