Skip to content

Commit

Permalink
Fix #2292: Sync request() and ws_connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Sep 28, 2017
1 parent c988fd0 commit ea8f50c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
18 changes: 17 additions & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ def ws_connect(self, url, *,
headers=None,
proxy=None,
proxy_auth=None,
verify_ssl=None,
fingerprint=None,
ssl_context=None,
proxy_headers=None,
compress=0):
"""Initiate websocket connection."""
return _WSRequestContextManager(
Expand All @@ -387,6 +391,10 @@ def ws_connect(self, url, *,
headers=headers,
proxy=proxy,
proxy_auth=proxy_auth,
verify_ssl=verify_ssl,
fingerprint=fingerprint,
ssl_context=ssl_context,
proxy_headers=proxy_headers,
compress=compress))

@asyncio.coroutine
Expand All @@ -402,6 +410,10 @@ def _ws_connect(self, url, *,
headers=None,
proxy=None,
proxy_auth=None,
verify_ssl=None,
fingerprint=None,
ssl_context=None,
proxy_headers=None,
compress=0):

if headers is None:
Expand Down Expand Up @@ -433,7 +445,11 @@ def _ws_connect(self, url, *,
read_until_eof=False,
auth=auth,
proxy=proxy,
proxy_auth=proxy_auth)
proxy_auth=proxy_auth,
verify_ssl=verify_ssl,
fingerprint=fingerprint,
ssl_context=ssl_context,
proxy_headers=proxy_headers)

try:
# check handshake
Expand Down
2 changes: 2 additions & 0 deletions changes/2292.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support `verify_ssl`, `fingerprint`, `ssl_context` and `proxy_headers`
by `client.ws_connect`.
47 changes: 31 additions & 16 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ The client session supports the context manager protocol for self closing.
max_redirects=10,\
compress=None, chunked=None, expect100=False,\
read_until_eof=True, proxy=None, proxy_auth=None,\
timeout=5*60, verify_ssl=None, fingerprint=None,
ssl_context=None)
timeout=5*60, verify_ssl=None, fingerprint=None, \
ssl_context=None, proxy_headers=None)
:async-with:
:coroutine:

Expand Down Expand Up @@ -484,7 +484,10 @@ The client session supports the context manager protocol for self closing.
autoping=True,\
heartbeat=None,\
origin=None, \
proxy=None, proxy_auth=None)
proxy=None, proxy_auth=None, \
verify_ssl=None, fingerprint=None, \
ssl_context=None, proxy_headers=None, \
compress=0)
:async-with:
:coroutine:

Expand Down Expand Up @@ -524,29 +527,41 @@ The client session supports the context manager protocol for self closing.
:param aiohttp.BasicAuth proxy_auth: an object that represents proxy HTTP
Basic Authorization (optional)

:param int compress: Enable Per-Message Compress Extension support.
0 for disable, 9 to 15 for window bit support.
Default value is 0.
:param bool verify_ssl: Perform SSL certificate validation for
*HTTPS* requests (enabled by default). May be disabled to
skip validation for sites with invalid certificates.

.. versionadded:: 0.16
.. versionadded:: 2.3

Add :meth:`ws_connect`.
:param bytes fingerprint: Pass the SHA256 digest of the expected
certificate in DER format to verify that the certificate the
server presents matches. Useful for `certificate pinning
<https://en.wikipedia.org/wiki/Transport_Layer_Security#Certificate_pinning>`_.

.. versionadded:: 0.18
Note: use of MD5 or SHA1 digests is insecure and deprecated.

Add *auth* parameter.
.. versionadded:: 2.3

.. versionadded:: 0.19
:param ssl.SSLContext ssl_context: ssl context used for processing
*HTTPS* requests (optional).

Add *origin* parameter.
*ssl_context* may be used for configuring certification
authority channel, supported SSL options etc.

.. versionadded:: 1.0
.. versionadded:: 2.3

Added ``proxy`` and ``proxy_auth`` parameters.
:param dict proxy_headers: HTTP headers to send to the proxy if the
parameter proxy has been provided.

.. versionchanged:: 1.1
.. versionadded:: 2.3


:param int compress: Enable Per-Message Compress Extension support.
0 for disable, 9 to 15 for window bit support.
Default value is 0.

.. versionadded:: 2.3

URLs may be either :class:`str` or :class:`~yarl.URL`

.. comethod:: close()

Expand Down

0 comments on commit ea8f50c

Please sign in to comment.