Repository navigation
fix(web): read the status of a recorded response in the hook dry run - #887
Open
thecorporatetractor wants to merge 2 commits into
Open
thecorporatetractor wants to merge 2 commits into
thecorporatetractor wants to merge 2 commits into
Conversation
The traffic recorder stores the response head as "HTTP <status>" with no version (traffic/traffic.go, stream.go, external.go). parseRawResponse required "HTTP/<version> <status>", so the match always failed and a dry run from a recorded exchange used status 200, whatever the response was. Make the version optional.
StartLine in http-code-block.tsx had the same HTTP/<version> pattern, so
recorded responses ("HTTP <status>") on the traffic, replay and evidence
views showed no status colour. Make the version optional there too.
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.
Problem
Traffic › Hooks › dry run from a recorded exchange uses status 200 for the response, whatever the recorded status was (WebSocket upgrades, stored as
HTTP/1.1 101, were already parsed).The recorder stores the response head as
HTTP <status>with no version (traffic/traffic.go:778,traffic/stream.go:317,traffic/external.go:57).parseRawResponse(web/src/lib/tamper-hooks.ts) requiresHTTP/<version> <status>, so the match always fails and it falls back to 200. A hook that branches on the status, such as one that only rewrites 404 responses, behaves differently in the dry run than on live traffic.Behavior change
The version is optional:
HTTP 404gives 404. A fullHTTP/1.1 404line still parses the same way.StartLineinweb/src/components/http-code-block.tsxhad the same pattern, so recorded responses showed no status colour on the traffic, replay and evidence views; it gets the same fix.Tested
New case in
web/scripts/tamper-hooks.test.mjs:HTTP 404\nContent-Type: text/plain\n\nnot foundgives status 404, its header and its body. It fails before the change.npm run test:tamper-hooks,tsc --noEmitand Biome pass.