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).
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 Resendbutton in the Headers side panel - Change the
Request Bodytext, e.g. keep justdatain it - Press the
Sendbutton in the form - The new HTTP request fail on timeout with status
408 Request Timeoutsince the request headercontent-lengthwas wrong
Honza
Some instructions for anyone interested in fixing this bug:
-
The
Request Bodytext 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
updateCustomRequestFieldsregistered 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
parseRequestTextwe can utilize here:
https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/devtools/client/netmonitor/src/components/CustomRequestPanel.js#84
Honza
Updated•1 year ago
|
| Assignee | ||
Comment 4•1 year 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•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 5•1 year ago
|
||
| Assignee | ||
Comment 6•1 year ago
|
||
PFA the patch.
The following are the details of the change:
Inside case "custom-postdata-value":
- Retrieve request headers
- Replace
content-lengthvalue 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-lengthvalue, they can edit the header value before sending. (Resolves Comment #4)
Kindly review the patch.
Pushed by jodvarko@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/23fa040f986a Modify content-length header with change in custom post data r=Honza
Comment 8•1 year ago
|
||
| bugherder | ||
Updated•1 year ago
|
Description
•