aiohttp.hdrs.SEC_WEBSOCKET_VERSION

Here are the examples of the python api aiohttp.hdrs.SEC_WEBSOCKET_VERSION taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: aiohttp Source File: test_client_ws_functional.py
@asyncio.coroutine
def test_override_default_headers(loop, test_client):

    @asyncio.coroutine
    def handler(request):
        assert request.headers[hdrs.SEC_WEBSOCKET_VERSION] == '8'
        ws = web.WebSocketResponse()
        yield from ws.prepare(request)

        ws.send_str('answer')
        yield from ws.close()
        return ws

    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', handler)
    headers = {hdrs.SEC_WEBSOCKET_VERSION: '8'}
    client = yield from test_client(app)
    resp = yield from client.ws_connect('/', headers=headers)
    msg = yield from resp.receive()
    assert msg.data == 'answer'
    yield from resp.close()