예제 #1
0
 def test_http_connect(self):
     ## Create a simple server with a filter that always responds with 'hello world'
     server = AsyncServer(('127.0.0.1', 15001), (self.routes,))
     server.start()
     
     try:
         resp = AsyncClient().get('http://127.0.0.1:15001/')
         print resp.read()
     except HTTPException, e:
         print "Status: %s Reason: %s" % (e.status, e.reason)
예제 #2
0
    def test_websocket(self):
        web_socket = WebSocket()
        web_socket.add('/', self.web_socket_handler)

        ## Create a simple server with a WebSocket filter that responds with 'Hello World'
        server = AsyncServer(('127.0.0.1', 15001), (web_socket,))
        server.start()

        #try:
        socket = AsyncClient().websocket('http://127.0.0.1:15001/')

        self.assertEquals(socket.headers['connection'], 'Upgrade')
        self.assertEquals(socket.headers['upgrade'], 'websocket')
        self.assertTrue('date' in socket.headers)
        self.assertTrue('sec-websocket-accept' in socket.headers)
        self.assertEquals(socket.status, 101)
        self.assertEquals(socket.reason, 'Switching Protocols')
        self.assertEquals(socket.read(),'hello world')

        #except HTTPException, e:
            #print "HTTP Exception Caught - Status: %s Reason: %s" % (e.status, e.reason)

        self.stop(server)
예제 #3
0
 def test_connect(self):
     resp = AsyncClient().get('http://127.0.0.1:15001/')
     print resp.read()