Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add headers to ws_connect coroutine #709

Merged
merged 2 commits into from
Dec 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ CHANGES

- Implement class based views #684

- Add *headers* parameter to ws_connect() #709

- Drop unused function `parse_remote_addr()` #708

- Close session on exception #707

- Store http code and headers in WSServerHandshakeError #706
>>>>>>> master
5 changes: 3 additions & 2 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,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 @@ -701,7 +701,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
Original file line number Diff line number Diff line change
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