Skip to content

Combine repeated Connection header fields during handshakes - #211

Open
6londe wants to merge 1 commit into
python-hyper:mainfrom
6londe:fix/repeated-connection-headers
Open

6londe wants to merge 1 commit into
python-hyper:mainfrom
6londe:fix/repeated-connection-headers

Conversation

@6londe

@6londe 6londe commented Nov 14, 2026

Copy link
Copy Markdown

Repeated Connection field lines are currently overwritten during both the server's request validation and the client's 101-response validation. A valid handshake containing:

Connection: Upgrade
Connection: keep-alive

raises RemoteProtocolError: Missing header, 'Connection: Upgrade' because only the final field's tokens are checked.

Accumulate tokens from every field line, using the existing comma-list parser and case-insensitive Upgrade check. Missing headers and lists without Upgrade continue to be rejected. This follows combined field-value handling in RFC 9110 §5.2–5.3 and the WebSocket handshake token requirement. The change is based directly on current main and is independent of #210.

Validation on macOS arm64:

  • Original main: 230 tests passed. New regression on unchanged main: 8 failed, 16 controls passed.
  • Python 3.10.20 and 3.12.13: all 254 tests passed (python -bb -m pytest; on 3.12 also --cov=wsproto --cov-report=term --cov-report=xml). Total line/branch coverage stays at 96.57%; all changed executable lines are covered.
  • An independent raw-socket peer over loopback TCP improved from 16/24 to 24/24 passing flows: both endpoint roles, token positions, mixed casing, comma lists, chunked reads, and missing-token/header rejection controls. Successful handshakes exchange a 640-byte PCM-shaped binary payload.
  • 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.

Other Python/platform combinations await upstream CI. Development groups were installed using uv pip install -e . --group dev in Python 3.12, avoiding the existing universal resolver conflict between Python 3.10 support and the Sphinx 8 documentation group; no dependency files changed.

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