Skip to content

Commit

Permalink
Add headers to ws_connect coroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Dec 25, 2015
1 parent 0ce2475 commit 5635451
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -40,3 +40,5 @@ CHANGES
- Close connection on websocket hadshake error #703

- Implement class based views #684

- Add *headers* parameter to ws_connect()
5 changes: 3 additions & 2 deletions aiohttp/client.py
Expand Up @@ -664,7 +664,7 @@ def delete(url, **kwargs):

def ws_connect(url, *, protocols=(), timeout=10.0, connector=None, auth=None,
ws_response_class=ClientWebSocketResponse, autoclose=True,
autoping=True, loop=None, origin=None):
autoping=True, loop=None, origin=None, headers=None):

if loop is None:
loop = asyncio.get_event_loop()
Expand All @@ -673,7 +673,8 @@ def ws_connect(url, *, protocols=(), timeout=10.0, connector=None, auth=None,
connector = aiohttp.TCPConnector(loop=loop, force_close=True)

session = aiohttp.ClientSession(loop=loop, connector=connector, auth=auth,
ws_response_class=ws_response_class)
ws_response_class=ws_response_class,
headers=headers)

return _DetachedWSRequestContextManager(
session._ws_connect(url,
Expand Down
10 changes: 9 additions & 1 deletion docs/client_websockets.rst
Expand Up @@ -59,7 +59,7 @@ coroutines, do not create an instance of class
timeout=10.0, connector=None, auth=None,\
ws_response_class=ClientWebSocketResponse,\
autoclose=True, autoping=True, loop=None,\
origin=None)
origin=None, headers=None)

This function creates a websocket connection, checks the response and
returns a :class:`ClientWebSocketResponse` object. In case of failure
Expand Down Expand Up @@ -97,6 +97,10 @@ coroutines, do not create an instance of class

:param str origin: Origin header to send to server

:param headers: :class:`dict`, :class:`CIMultiDict` or
:class:`CIMultiDictProxy` for providing additional
headers for websocket handshake request.

.. versionadded:: 0.18

Add *auth* parameter.
Expand All @@ -105,6 +109,10 @@ coroutines, do not create an instance of class

Add *origin* parameter.

.. versionadded:: 0.20

Add *headers* parameter.


ClientWebSocketResponse
-----------------------
Expand Down

0 comments on commit 5635451

Please sign in to comment.