[Python-checkins] python/dist/src/Lib/test test_httplib.py,1.5,1.6

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
2002年7月07日 09:51:39 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv14230/test
Modified Files:
	test_httplib.py 
Log Message:
Fix for SF bug #432621: httplib: multiple Set-Cookie headers
If multiple header fields with the same name occur, they are combined
according to the rules in RFC 2616 sec 4.2:
Appending each subsequent field-value to the first, each separated by
a comma. The order in which header fields with the same field-name are
received is significant to the interpretation of the combined field
value.
Index: test_httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_httplib.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_httplib.py	28 Jun 2002 23:54:30 -0000	1.5
--- test_httplib.py	7 Jul 2002 16:51:37 -0000	1.6
***************
*** 16,20 ****
 body = "HTTP/1.1 200 Ok\r\n\r\nText"
 sock = FakeSocket(body)
! resp = httplib.HTTPResponse(sock,1)
 resp._begin()
 print resp.read()
--- 16,20 ----
 body = "HTTP/1.1 200 Ok\r\n\r\nText"
 sock = FakeSocket(body)
! resp = httplib.HTTPResponse(sock, 1)
 resp._begin()
 print resp.read()
***************
*** 23,27 ****
 body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
 sock = FakeSocket(body)
! resp = httplib.HTTPResponse(sock,1)
 try:
 resp._begin()
--- 23,27 ----
 body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
 sock = FakeSocket(body)
! resp = httplib.HTTPResponse(sock, 1)
 try:
 resp._begin()
***************
*** 40,41 ****
--- 40,59 ----
 else:
 print "Expect InvalidURL"
+ 
+ # test response with multiple message headers with the same field name.
+ text = ('HTTP/1.1 200 OK\r\n'
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n'
+ 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";'
+ ' Path="/acme"\r\n'
+ '\r\n'
+ 'No body\r\n')
+ hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"'
+ ', '
+ 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"')
+ s = FakeSocket(text)
+ r = httplib.HTTPResponse(s, 1)
+ r._begin()
+ cookies = r.getheader("Set-Cookie")
+ if cookies != hdr:
+ raise AssertionError, "multiple headers not combined properly"
+ 

AltStyle によって変換されたページ (->オリジナル) /