inspector: fix absolute URLs in network http#62955
Open
GrinZero wants to merge 1 commit intonodejs:mainfrom
Open
inspector: fix absolute URLs in network http#62955GrinZero wants to merge 1 commit intonodejs:mainfrom
GrinZero wants to merge 1 commit intonodejs:mainfrom
Conversation
Some HTTP clients send an absolute URL in request.path. The network\ninspection code always prefixed request.protocol and host,\nwhich produced duplicated URLs such as\nhttp://hosthttp://host/path in Network.requestWillBeSent and\nNetwork.responseReceived.\n\nHandle absolute URL paths directly and keep the existing\nrelative-path behavior unchanged.\n\nExtend the HTTP inspector test to cover both GET and POST\nrequests that use an absolute URL as options.path and verify\nthat getResponseBody still returns the expected payload.\n\nSigned-off-by: GrinZero <[email protected]>
Collaborator
|
Review requested:
|
Author
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.


Summary
This PR fixes incorrect URL reporting in the HTTP network inspector when a client passes an absolute URL as
options.path.Before this change, the inspector always constructed the request URL as:
That works for normal relative paths such as
/hello-world, but it breaks whenrequest.pathalready contains a full URL, producing values like:As a result, DevTools shows an incorrect
Request URLinNetwork.requestWillBeSentandNetwork.responseReceived.Problem
Observed behavior:
request.pathshape/hello-worldhttp://127.0.0.1:3000/hello-worldhttp://127.0.0.1:3000/hello-worldhttp://127.0.0.1:3000/hello-worldhttp://127.0.0.1:3000http://127.0.0.1:3000/hello-worldhttp://127.0.0.1:3000/hello-worldThis was reproducible with HTTP clients that forward an absolute URL through the
pathfield.Solution
The fix keeps the existing behavior for relative paths and adds a guard for absolute URL paths.
Behavior after this change:
request.pathstarts withhttp://orhttps://, use it directly.protocol,host, andpath.This keeps the patch small and isolates it from the compressed-response work, which will be handled separately.
Tests
The existing HTTP inspector test was extended to cover:
GETGETPOSTThe
POSTcase also verifies thatNetwork.getResponseBody()still returns the expected payload.