feat: add ssl parameter to ClientSession#13021
Conversation
Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13021 +/- ##
==========================================
- Coverage 98.96% 98.95% -0.01%
==========================================
Files 131 131
Lines 48156 48195 +39
Branches 2499 2502 +3
==========================================
+ Hits 47656 47693 +37
- Misses 376 377 +1
- Partials 124 125 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
- Include _SENTINEL in the type annotation for the ssl parameter of _request, ws_connect, and _ws_connect so mypy accepts the sentinel default value. - Add test_default_ssl_ws to cover the default ssl propagation in websocket connections. - Add CHANGES fragment for aio-libs#13021. Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
| headers: LooseHeaders | None | ||
| proxy: StrOrURL | None | ||
| ssl: SSLContext | bool | Fingerprint | ||
| ssl: SSLContext | bool | Fingerprint | _SENTINEL |
There was a problem hiding this comment.
How come this one has changed, but the _request one hasn't?
Add an
sslparameter toClientSessionthat is used as the default SSL setting for all requests made by the session.Closes #13006.
Summary
This allows users to configure SSL once on the session instead of either:
ssl=...to every request.TCPConnector(ssl=...)manually, which is less intuitive.When a request is made without an explicit
sslargument, the session's default is used. Per-requestsslvalues still override the session default.Changes
sslparameter toClientSession.__init__._default_ssl._requestand_ws_connectto fall back to_default_sslwhensslis not provided.test_default_sslverifying both session default and per-request override.Tests
Ran the new test and existing proxy/ssl session tests locally:
Result: 3 passed, 1 skipped.