New issue
Advanced search Search tips

Issue 851874 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 8
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

"Copy as Fetch" doesn't contain all the relevant headers (Copy as cURL works fine though)

Reported by rocca.jo...@gmail.com, Jun 12 2018

Issue description

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

Steps to reproduce the problem:
1. Load any website with the network tab of dev tools open
2. Right click on any request and copy as fetch
3. Right click again and copy as curl
4. Notice that the curl request has more headers

What is the expected behavior?
The "copy as fetch" feature should properly emulate the fetch, just like the "copy as curl" feature.

What went wrong?
Here's an example request (with `body` and `url` changed to "foobar" to hide info):

fetch("http://example.com", {"credentials":"omit","headers":{},"referrer":"http://example.com","referrerPolicy":"no-referrer-when-downgrade","body":"foobar","method":"POST","mode":"cors"});

curl 'http://example.com' -H 'Origin: http://example.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.17 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'Referer: http://example.com' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'foobar' --compressed

The curl request worked fine, but I got an internal server error (500) for the `fetch` because it doesn't include this header: 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'

Did this work before? N/A 

Chrome version: 67.0.3396.62  Channel: n/a
OS Version: 16.04.04
Flash Version:
 
Labels: Needs-Triage-M67

Comment 2 by l...@chromium.org, Jun 12 2018

Owner: l...@chromium.org
Status: Assigned (was: Unconfirmed)
I was going to file a bug for this and on the 1st page of the wizard saw that "I have searched ..." and eventually I got here.

Just wanna add a comment that "Content-Type" header is critical, as a simple use case of flow: 1. Copy as fetch, 2.Paste and run in console, does not work for forms at all.

Cc: phistuck@chromium.org
Status: Fixed (was: Assigned)
Looks like this was fixed by:
https://chromium-review.googlesource.com/c/chromium/src/+/1162228

The fix landed recently, so it will take time to reach stable.
I am sorry for this stupid bug, people. This is indeed fixed in Chrome 70.
Cc: l...@chromium.org
 Issue 877379  has been merged into this issue.

Sign in to add a comment