Resend requests should set the correct content-length header
Categories
(DevTools :: Netmonitor, defect, P3)
Tracking
(firefox77 fixed)
Tracking | Status | |
---|---|---|
firefox77 | --- | fixed |
People
(Reporter: Harald, Assigned: ojaswa1942)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug)
Attachments
(1 file)
Reported via https://discourse.mozilla.org/t/reset-content-length-header-when-editing-and-resending-requests/56037
Should be either removed or reset to the correct length (my favorite).
Comment 2•5 years ago
|
||
STR:
- Open DevTools and Select the Network panel
- Load http://janodvarko.cz/firebug/tests/601/Issue601.htm
- Click the POST button on the page
- Select the request and click the
Edit and Resend
button in the Headers side panel - Change the
Request Body
text, e.g. keep justdata
in it - Press the
Send
button in the form - The new HTTP request fail on timeout with status
408 Request Timeout
since the request headercontent-length
was wrong
Honza
Comment 3•5 years ago
|
||
Some instructions for anyone interested in fixing this bug:
-
The
Request Body
text area (for POST data) is rendered here:
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#332-340 -
There is a change handler
updateCustomRequestFields
registered foronChange
It's implemented in the same file:
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#105 -
We are interested when the POST data changes so
case "custom-postdata-value"
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#127
In this case we need to parse request headers text and update the Content-Length
header (using the current POST data length).
Related text area is rendered here:
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#310-318
- Luckily we already have
parseRequestText
we can utilize here:
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#84
Honza
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
As I can see, we can edit both Request Body
and Request Headers
, making it possible for user to set the content-length
property. If I correctly understand the problem, if we correct the value to correct length, won't it be a problem for user who don't intend to send correct value? I mean, it is very possible for someone wishing to change the length as per his requirements, specially if he's sending a custom request.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
Assignee | ||
Comment 6•5 years ago
|
||
PFA the patch.
The following are the details of the change:
Inside case "custom-postdata-value"
:
- Retrieve request headers
- Replace
content-length
value in request headers by new content-length - Update both postData and headers
New behavior:
- Only content length header changes with data (Other header values remain same)
- In case someone wants to send a different
content-length
value, they can edit the header value before sending. (Resolves Comment #4)
Kindly review the patch.
Comment 8•5 years ago
|
||
bugherder |
Updated•4 years ago
|
Description
•