1.1 --- a/Python/BLIPListenerTest.py Tue Jun 23 11:44:30 2009 -0700
1.2 +++ b/Python/BLIPListenerTest.py Fri Jul 24 14:06:28 2009 -0700
1.3 @@ -17,8 +17,13 @@
1.4 class BLIPListenerTest(unittest.TestCase):
1.5
1.6 def testListener(self):
1.7 + def handleConnection(conn):
1.8 + logging.info("Got new connection: %r", conn)
1.9 + conn.ListenerTestNumRequests = 0
1.10 +
1.11 def handleRequest(request):
1.12 logging.info("Got request!: %r",request)
1.13 + request.connection.ListenerTestNumRequests += 1
1.14 body = request.body
1.15 assert len(body)<32768
1.16 assert request.contentType == 'application/octet-stream'
1.17 @@ -31,8 +36,11 @@
1.18 response.body = request.body
1.19 response['Content-Type'] = request.contentType
1.20 response.send()
1.21 + if request.connection.ListenerTestNumRequests >= 50:
1.22 + request.connection.close()
1.23
1.24 listener = Listener(46353)
1.25 + listener.onConnected = handleConnection
1.26 listener.onRequest = handleRequest
1.27 logging.info("Listener is waiting...")
1.28
1.29 @@ -42,5 +50,5 @@
1.30 logging.info("KeyboardInterrupt")
1.31
1.32 if __name__ == '__main__':
1.33 - logging.basicConfig(level=logging.DEBUG)
1.34 + logging.basicConfig(level=logging.INFO)
1.35 unittest.main()