Skip to content

Preserve the first accepted extension offer - #210

Open
6londe wants to merge 1 commit into
python-hyper:mainfrom
6londe:fix/preserve-negotiated-extension-state
Open

6londe wants to merge 1 commit into
python-hyper:mainfrom
6londe:fix/preserve-negotiated-extension-state

Conversation

@6londe

@6londe 6londe commented Nov 13, 2026

Copy link
Copy Markdown

A supported permessage-deflate offer followed by an unsupported alternative can change the extension object after the response parameters have been chosen. For example, a later client_no_context_takeover; server_max_window_bits=8 offer is declined, but leaves context takeover disabled internally while the response still allows it. The first compressed message succeeds; the second closes with a decompression error.

Keep the first accepted offer for each extension name and skip later alternatives. Declined offers still allow fallback, and other extension names are still processed. This follows the client preference order described in RFC 7692 §5.

Validation:

  • Original main: 230 tests passed. Final regression tests against unchanged main: 11 failed, 9 controls passed.
  • Python 3.10.20 and 3.12.13: all 250 tests passed (python -bb -m pytest; on 3.12 also --cov=wsproto --cov-report=term --cov-report=xml). Line/branch coverage increased from 96.57% to 97.11%; both added source lines and both guard branches are covered.
  • mypy src/ (strict), Ruff check/format for the new test, make -C docs clean html, check-manifest, python -m build --outdir dist/, and twine check dist/* passed.
  • A local TCP echo flow with an independent raw-socket/zlib peer improved from 8/16 to 16/16 passing scenarios: text/binary, repeated/comma-separated extension headers, whole/chunked transport, with/without the rejected alternative, two messages per connection.

Validated on macOS arm64. Other Python/platform combinations await upstream CI. The existing UV all-groups resolver fails on the project's Python 3.10/Sphinx 8 constraint; the declared groups were installed into the Python 3.12 environment using uv pip install -e . --group dev, without changing dependencies.

Prepared with OpenAI Codex automation. No human review is claimed.

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