improve/http2 - #574
Merged
Merged
improve/http2#574
Conversation
sonic182
commented
Feb 17, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.