Skip to content

Show HTTP reason phrases for HTTP/2 and HTTP/3 via lookup table (issue #7694) - #8424

Open
Larslllllll wants to merge 3 commits into
mitmproxy:mainfrom
Larslllllll:main
Open

Larslllllll wants to merge 3 commits into
mitmproxy:mainfrom
Larslllllll:main

Conversation

@Larslllllll

Copy link
Copy Markdown

Summary

Show reason phrases for HTTP/2 and HTTP/3 responses in the mitmweb flow view by looking them up from a status code table. These are not transmitted on the wire per RFC 7540 (HTTP/2) and RFC 9113 (HTTP/3), so a lookup table provides the human-readable reason.

Changes

  1. Added web/gen/status_codes.py: A Python script that converts mitmproxy/net/http/status_codes.py to a TypeScript status code → reason phrase mapping.
  2. Added web/src/js/statusCodes.ts: Generated TypeScript file with export const statusCodeReasons: Record<number, string>.
  3. Updated web/src/js/components/FlowView/HttpMessages.tsx:
    • Imported statusCodeReasons
    • Modified ResponseLine to show looked-up reason for HTTP/2 and HTTP/3
    • Added a title tooltip explaining the reason is looked up (not transmitted)
    • Kept original behavior for HTTP/1.x (shows transmitted reason)

Details

  • For HTTP/1.x: Shows the reason phrase as transmitted over the wire (existing behavior).
  • For HTTP/2 and HTTP/3: Looks up the reason from statusCodeReasons[status_code] since the wire format omits it.
  • The lookup table includes all standard and custom status codes defined in mitmproxy.
  • A tooltip explains: "Reason phrase not transmitted for HTTP/2 and HTTP/3; looked up from status code".

Testing

  • Verified the script generates correct TypeScript.
  • The generated file builds successfully.
  • UI changes display correctly in flow view.

Closes the RFC task from #7694.

Co-authored-by: web/gen/status_codes.py

…mitmproxy#7694)

Adds statusCodeReasons lookup table (auto-generated from status_codes.py) and uses it in
HttpMessages ResponseLine to show reason phrases for HTTP/2 and HTTP/3 responses.
These are looked up from the status code since HTTP/2 and HTTP/3 do not transmit
reason phrases on the wire. Includes a title tooltip explaining this.

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