Skip to content

feat: add ssl parameter to ClientSession#13021

Open
NIK-TIGER-BILL wants to merge 2 commits into
aio-libs:masterfrom
NIK-TIGER-BILL:feat/client-session-ssl
Open

feat: add ssl parameter to ClientSession#13021
NIK-TIGER-BILL wants to merge 2 commits into
aio-libs:masterfrom
NIK-TIGER-BILL:feat/client-session-ssl

Conversation

@NIK-TIGER-BILL

Copy link
Copy Markdown

Add an ssl parameter to ClientSession that 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:

  • Passing ssl=... to every request.
  • Creating a TCPConnector(ssl=...) manually, which is less intuitive.

When a request is made without an explicit ssl argument, the session's default is used. Per-request ssl values still override the session default.

Changes

  • Added ssl parameter to ClientSession.__init__.
  • Stored it as _default_ssl.
  • Updated _request and _ws_connect to fall back to _default_ssl when ssl is not provided.
  • Added test_default_ssl verifying both session default and per-request override.

Tests

Ran the new test and existing proxy/ssl session tests locally:

python -m pytest tests/test_client_session.py::test_default_ssl tests/test_client_session.py::test_default_proxy tests/test_client_session.py::test_ssl_shutdown_timeout_passed_to_connector tests/test_client_session.py::test_proxy_str -v

Result: 3 passed, 1 skipped.

Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
@NIK-TIGER-BILL NIK-TIGER-BILL requested a review from asvetlov as a code owner June 30, 2026 23:37
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.95%. Comparing base (8ef76ab) to head (1654c96).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
aiohttp/client.py 75.00% 1 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
Autobahn 22.20% <10.25%> (-0.01%) ⬇️
CI-GHA 98.90% <95.00%> (-0.01%) ⬇️
OS-Linux 98.66% <95.00%> (-0.01%) ⬇️
OS-Windows 97.04% <95.00%> (-0.01%) ⬇️
OS-macOS 97.94% <95.00%> (-0.01%) ⬇️
Py-3.10 98.14% <95.00%> (-0.01%) ⬇️
Py-3.11 98.41% <95.00%> (-0.01%) ⬇️
Py-3.12 98.50% <95.00%> (-0.01%) ⬇️
Py-3.13 98.47% <95.00%> (-0.01%) ⬇️
Py-3.14 98.49% <94.87%> (+<0.01%) ⬆️
Py-3.14t 97.58% <94.87%> (-0.01%) ⬇️
Py-pypy-3.11 97.44% <95.00%> (-0.01%) ⬇️
VM-macos 97.94% <95.00%> (-0.01%) ⬇️
VM-ubuntu 98.66% <95.00%> (-0.01%) ⬇️
VM-windows 97.04% <95.00%> (-0.01%) ⬇️
cython-coverage 38.09% <10.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 83 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing NIK-TIGER-BILL:feat/client-session-ssl (1654c96) with master (8ef76ab)

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

- 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>
@NIK-TIGER-BILL NIK-TIGER-BILL requested a review from webknjaz as a code owner July 1, 2026 03:27
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ssl parameter to the ClientSession

1 participant