Skip to content

improve/http2 - #574

Merged
sonic182 merged 17 commits into
masterfrom
improve/http2
Feb 18, 2026
Merged

sonic182 merged 17 commits into
masterfrom
improve/http2

Conversation

@sonic182

Copy link
Copy Markdown
Owner
  • replace black with ruff for formatting and linting
  • format and http2 at client level

- Update pyproject.toml: switch to ruff-only toolchain (remove black,
  pytest-black), set line-length=119, target-version=py312, add T201
  rule and exclude dirs
- Remove --black from pytest addopts in pytest.ini
- Fix all ruff violations in aiosonic/ and tests/
- Update AGENTS.md to reference ruff instead of black
- Fix test_http2: drop invalid assert res.chunked (HTTP/2 has no chunked
  transfer encoding) and remove test_get_image_chunked which relied on it
When http2=True and a custom ssl context is passed, set_alpn_protocols
is called best-effort so TLS negotiation advertises h2. Also adds tests
for verify=False on h2 contexts and custom ctx ALPN injection.
Replace the 5s timeout fallback (which sent data regardless of window)
with a proper wait loop: block until local_flow_control_window > 0,
then chunk with min(window, max_frame). Updates unit test to assert the
correct behaviour instead of the broken timeout fallback.
Mark HTTP/2 handlers as closing on disconnect events so pending streams fail and new streams are rejected, and scope CI lint to aiosonic/tests/aiosonic_utils. Also fix a long logging line in performance script.
TCPConnector now accepts an http2 flag and defaults pool_cls to
Http2MultiplexPool when it is set, removing the need for callers to
pass pool_cls explicitly. HTTPClient forwards the flag to the
auto-created connector, and the benchmark script is simplified
accordingly.
On Python 3.10, h2 can deliver ResponseReceived, DataReceived, and
StreamEnded in a single batch. The premature None sentinel injected in
_on_response_received (guarded by checking h2conn.streams) fired before
DataReceived was processed, causing read_chunks to exit early and return
an empty body. Removed the check entirely: StreamEnded always fires and
is the correct place to put the None terminator.
@sonic182
sonic182 merged commit 2be0102 into master Feb 18, 2026
17 checks passed
@sonic182
sonic182 deleted the improve/http2 branch February 18, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant