Skip to content

Fix Hypercorn's HTTP/3 handling of informational responses - #381

Open
code-1py wants to merge 1 commit into
pgjones:mainfrom
code-1py:fix/informational-responses-http3
Open

code-1py wants to merge 1 commit into
pgjones:mainfrom
code-1py:fix/informational-responses-http3

Conversation

@code-1py

Copy link
Copy Markdown

Summary

Fix Hypercorn's HTTP/3 handling of informational responses such as 103 Early Hints. aioquic currently advances its header send state for every HEADERS frame, including interim responses, as described in aioquic issue #656. This can leave the stream in the wrong state for final response headers and response DATA.

This change adds a Hypercorn-side workaround while the upstream fix in aioquic pull request #657 is pending. With this change, Hypercorn can send HTTP/3 informational responses without prematurely advancing the headers send state.

Changes

  • Add H3Wrapper, a subclass of aioquic's H3Connection, with a custom send_headers() implementation.
  • Detect Hypercorn InformationalResponse events in H3Protocol.stream_send() and pass is_informational=True to the wrapper.
  • Preserve the headers send state for informational headers; advance it for final response headers so DATA and optional trailers can follow.
  • Reject informational headers with end_stream=True and informational headers sent after final response headers.

Tests

  • Verify one or multiple informational responses leave the send state in INITIAL, then final response headers advance it to AFTER_HEADERS and DATA can end the stream.
  • Verify informational headers cannot end the stream.
  • Verify informational headers cannot be sent after final response headers.

References

Related issue: #380

- Wrap aioquic's H3Connection with a Hypercorn H3Wrapper that implement own send_headers function to preserves the headers send state to INITIAL for informational headers.
- Pass is_informational=True for InformationalResponse events, while advancing the state for final response headers so response DATA can follow.
- Reject informational headers that end the stream or follow final headers.
- Add tests for one or multiple interim responses, the final response and DATA sequence, and invalid informational header ordering.

This branch has not been deployed

No deployments
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