Changeset 1255
- Timestamp:
- 08/20/06 15:51:30
- Files:
-
- trunk/cherrypy/test/benchmark.py (modified) (1 diff)
- trunk/cherrypy/test/test.py (modified) (1 diff)
- trunk/cherrypy/test/test_conn.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/benchmark.py
r1251 r1255 185 185 assert self.concurrency > 0 186 186 assert self.requests > 0 187 return ("- n %s -c %s http://localhost:%s%s" %187 return ("-k -n %s -c %s http://localhost:%s%s" % 188 188 (self.requests, self.concurrency, port, self.path)) 189 189 trunk/cherrypy/test/test.py
r1252 r1255 308 308 'test_caching', 309 309 'test_config', 310 'test_conn', 310 311 'test_core', 311 312 'test_tools', trunk/cherrypy/test/test_conn.py
r1253 r1255 19 19 page2 = index 20 20 page3 = index 21 22 def hello(self): 23 return "Hello, world!" 24 hello.exposed = True 21 25 22 26 def stream(self): … … 42 46 # Set our HTTP_CONN to an instance so it persists between requests. 43 47 self.HTTP_CONN = httplib.HTTPConnection(self.HOST, self.PORT) 48 # Don't automatically re-connect 49 self.HTTP_CONN.auto_open = False 50 self.HTTP_CONN.connect() 44 51 45 52 # Make the first request and assert there's no "Connection: close". … … 56 63 57 64 # Make another, streamed request on the same connection. 65 # Streamed output closes the connection to determine transfer-length. 58 66 self.getPage("/stream") 59 67 self.assertStatus('200 OK') 60 68 self.assertBody('0123456789') 61 # Streamed output closes the connection to determine transfer-length.62 69 self.assertHeader("Connection", "close") 63 70 64 # Make another request on a new connection, but close it. 71 # Make another request on the same connection, which should error. 72 self.assertRaises(httplib.NotConnected, self.getPage, "/") 73 74 # Test client-side close. 65 75 self.HTTP_CONN = httplib.HTTPConnection(self.HOST, self.PORT) 66 76 self.getPage("/page2", headers=[("Connection", "close")]) … … 68 78 self.assertBody(pov) 69 79 self.assertHeader("Connection", "close") 80 81 def test_HTTP11_pipelining(self): 82 # Test pipelining. httplib doesn't support this directly. 83 conn = httplib.HTTPConnection(self.HOST, self.PORT) 84 conn.auto_open = False 85 conn.connect() 70 86 71 # Make another request on the same connection, which should error. 72 # This doesn't work with httplib, because it spawns a new socket as needed. 73 ## self.assertRaises(socket.timeout, self.getPage, "/") 87 # Put request 1 88 conn.putrequest("GET", "/", skip_host=True) 89 conn.putheader("Host", self.HOST) 90 conn.endheaders() 74 91 75 # XXX Test pipelining. httplib doesn't support this. 92 # Put request 2 93 conn._output('GET /hello HTTP/1.1') 94 conn._output("Host: %s" % self.HOST) 95 conn._send_output() 76 96 97 # Retrieve response 1 98 response = conn.response_class(conn.sock, method="GET") 99 response.begin() 100 body = response.read() 101 self.assertEqual(response.status, 200) 102 self.assertEqual(body, pov) 77 103 104 # Retrieve response 2 105 response = conn.response_class(conn.sock, method="GET") 106 response.begin() 107 body = response.read() 108 self.assertEqual(response.status, 200) 109 self.assertEqual(body, "Hello, world!") 110 111 conn.close() 112 78 113 def test_HTTP10(self): 79 114 self.PROTOCOL = "HTTP/1.1"

