New issue
Advanced search Search tips

Issue 719244 link

Starred by 1 user

Issue metadata

Status: Archived
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Content length is not being set for DELETE & PATCH requests with empty body

Reported by beku2...@gmail.com, May 7 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.81 Chrome/58.0.3029.81 Safari/537.36

Steps to reproduce the problem:
1. Send DELETE/PATCH or ajax request with empty body
2. Investigate the request headers
3. There won't be Content-Length: 0

What is the expected behavior?
For POST/PUT requests following header "Content-Length: 0" is sent with the request. I expect the same with DELETE/PATCH requests.

What went wrong?
Not sending Content-Length header at all. 

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 58.0.3029.81  Channel: n/a
OS Version: 
Flash Version:
 
Cc: kkaluri@chromium.org
Labels: Needs-Feedback
beku2009@ Could you please help us with the sample html case for this issue for further triage.

Thank You...
Labels: Needs-Triage-M58
Components: Internals>Network>HTTP

Comment 4 by mmenke@chromium.org, Feb 15 2018

Components: -Internals>Network>HTTP Internals>Network
It looks like we attach Content-Length as long as there's a non-null body (https://cs.chromium.org/chromium/src/net/http/http_network_transaction.cc?type=cs&sq=package:chromium&l=1049 - also attaches a length unconditionally for POST/PUT), so we're presumably either nulling out or not sending the body at some higher layer, since it's empty, so we just need to determine what layer that is.

Skimming over the fetch spec, it does sound like we should be sending Content-Length as long as the request body is non-null:

5. If httpRequest’s body is null and httpRequest’s method is `POST` or `PUT`, then set contentLengthValue to `0`.
6. If httpRequest’s body is non-null and httpRequest’s body’s source is non-null, then set contentLengthValue to httpRequest’s body’s total bytes, UTF-8 encoded.
7. If contentLengthValue is non-null, append `Content-Length`/contentLengthValue to httpRequest’s header list.

(I'm assuming the body "body source" is non-null)

Punting to the general triage queue - per above comment, unclear what layer this is.

Comment 5 by rch@chromium.org, Feb 21 2018

mmenke: are we still waiting for feedback on this one?
Components: Blink>Loader
Labels: -Needs-Feedback
Removing Needs-Feedback. Seems easy enough to reproduce. Let me also attach Blink>Loader so this is on their radar.
Labels: Needs-Feedback
I've tried to repro this on the following page:
http://cr.kungfoo.net/delete/

This page has the following JS:
fetch('/does-not-exist-xxx', {
  method: 'delete',
  body: ""
});

net-internals shows me that we *are* sending Content-Length: 0.

beku2009@, can you post code for how you are issuing the DELETE (or even better, a test page)?
Oh also, could you please update to the latest Chrome version 64? Chrome 58 is very old at this point has things have changed substantially (including many important security fixes).
ping beku2009@, can you respond to #7 and #8?

Comment 10 by rch@chromium.org, May 17 2018

Status: Archived (was: Unconfirmed)
Please feel free to open a new bug if you can include the information requested in #7 and #8.

Sign in to add a comment