Python implementation much improved. Can send requests now. Fully interoperable with Obj-C implementation's test cases.
6 Created by Jens Alfke on 2008-06-04.
7 This source file is test/example code, and is in the public domain.
10 from BLIP import Listener
17 class BLIPListenerTest(unittest.TestCase):
19 def testListener(self):
20 def handleRequest(request):
21 logging.info("Got request!: %r",request)
23 assert len(body)<32768
24 assert request.contentType == 'application/octet-stream'
25 assert int(request['Size']) == len(body)
26 assert request['User-Agent'] != None
27 for i in xrange(0,len(request.body)):
28 assert ord(body[i]) == i%256
30 response = request.response
31 response.body = request.body
32 response['Content-Type'] = request.contentType
35 listener = Listener(46353)
36 listener.onRequest = handleRequest
37 logging.info("Listener is waiting...")
41 except KeyboardInterrupt:
42 logging.info("KeyboardInterrupt")
44 if __name__ == '__main__':
45 logging.basicConfig(level=logging.INFO)