[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/tests - testHTTPServer.py:1.1.2.5
Shane Hathaway
shane@digicool.com
Wed, 28 Nov 2001 11:02:33 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/tests
In directory cvs.zope.org:/tmp/cvs-serv22466/tests
Modified Files:
Tag: Zope-3x-branch
testHTTPServer.py
Log Message:
Added tests of chunking requests and fixed implementation errors.
=== Zope3/lib/python/Zope/Server/tests/testHTTPServer.py 1.1.2.4 => 1.1.2.5 ===
self.failUnlessEqual(len(tasks.threads), 1)
+ def testChunkingRequestWithoutContent(self):
+ h = HTTPConnection(LOCALHOST, self.port)
+ h.putrequest('GET', '/')
+ h.putheader('Accept', 'text/plain')
+ h.putheader('Transfer-Encoding', 'chunked')
+ h.endheaders()
+ h.send("0\r\n\r\n")
+ response = h.getresponse()
+ self.failUnlessEqual(int(response.status), 200)
+ response_body = response.read()
+ self.failUnlessEqual(response_body, '')
+
+ def testChunkingRequestWithContent(self):
+ control_line="32;\r\n"
+ s = 'This string has 32 characters.\r\n'
+ expect = s * 12
+
+ h = HTTPConnection(LOCALHOST, self.port)
+ h.putrequest('GET', '/')
+ h.putheader('Accept', 'text/plain')
+ h.putheader('Transfer-Encoding', 'chunked')
+ h.endheaders()
+ for n in range(12):
+ h.send(control_line)
+ h.send(s)
+ h.send("0\r\n\r\n")
+ response = h.getresponse()
+ self.failUnlessEqual(int(response.status), 200)
+ response_body = response.read()
+ self.failUnlessEqual(response_body, expect)
+
def test_suite():
loader = unittest.TestLoader()