New issue
Advanced search Search tips

Issue 914359 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 827582
Owner: ----
Closed: Jan 3
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug
Proj-Servicification



Sign in to add a comment

I cannot modify the HTTP response headers with Chrome extension on Windows Chrome

Reported by jinlimi...@gmail.com, Dec 12

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3638.0 Safari/537.36

Steps to reproduce the problem:
1. Load the extension.
2. Open a new tab.
3. Open the Developer tools.
4. Go to a website.
5. Check the Network Tab in the Developer tools.

What is the expected behavior?
Response headers of all requests should be modified.

What went wrong?
It can only successfully modify the response headers of part resources loaded in the website, but not work on the main HTML file request and other parts of requests.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 73.0.3638.0  Channel: canary
OS Version: 10.0
Flash Version: 

I cannot modify the HTTP response headers with Chrome extension on Windows Chrome. This happens for a long time, the first time I found the problem is probably in version 63, I keep upgrade Chrome to the each newest version, but it doesn't help.
I tried some other extensions in the Chrome Store, also encountered the same issue.
The code looks like this:
```javascript
chrome.webRequest.onHeadersReceived.addListener(details => {
    details.responseHeaders.push({ name: 'X-Test-Header', value: 'test' });
    return { responseHeaders: details.responseHeaders };
}, {urls: ["<all_urls>"]}, ["responseHeaders", "blocking"]);
```
This code works fine on my Mac, but not on my Windows 10.
===
I found that my extension can successfully modify the response headers of part resources loaded in the website, but not work on the main HTML file request. so I think the problem was not in my code.
 
Do you have other extensions?
If so, try disabling them all, then enable one by one until you find the culprit.

Quoting https://developer.chrome.com/extensions/webRequest#conflict_resolution:

  Only one extension is allowed to redirect a request or modify a header at a time.
  If more than one extension attempts to modify the request,
  the most recently installed extension wins and all others are ignored.
  An extension is not notified if its instruction to modify or redirect has been ignored.

Components: Platform>Extensions
Labels: Needs-Triage-M73
I tried to disable all extensions, even uninstalled them all, but I still got the same issue.
Cc: viswa.karala@chromium.org
Labels: Triaged-ET Needs-Feedback
Tried testing the issue on chrome reported version# 73.0.3638.0 using Windows-10 with steps mentioned below:
1) Launched chrome reported version and installed extension from chrome://extensions
2) Opened New Tab Page > Devtools > Network tab and navigated to website(ex: fb.com)
3) Able to see requests generated in network tab(find attahced for the same)

@Reporter: Please find the attached screencast for your reference and let us know if we missed anything in reproducing the issue. If possible provide the sample extension and screencast of the issue which help in better understanding and further triaging it in better way.

Thanks!
914359.mp4
5.2 MB View Download
Screencast file is too large, and I uploaded it to YouTube.
Here is the private link: https://youtu.be/SHA-HBrlMmo
Project Member

Comment 6 by sheriffbot@chromium.org, Dec 14

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: swarnasree.mukkala@chromium.org
Labels: Needs-Feedback
@reporter: Could you please provide a sample extension file as requested in comment#4, which was used in screencast provided in comment#5 so that it would be really helpful in further triaging of the issue.

Thanks.!
The sample extension file used in screencast provided in comment#5:
ChromeExtensions.tar.gz
471 bytes Download
Project Member

Comment 9 by sheriffbot@chromium.org, Dec 29

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: cduvall@chromium.org
Do you have the Network Service enabled?
Does the problem reproduce if you disable it from chrome://flags/#network-service ?
The status of Network Service is the default.

I found that when I upgrade to the latest Canary version, the issue seems like solved. I can successfully modify the value of Content-Type to 'text/plain' in the response headers, and it works, the web page displayed in plain text. But when I open the DevTools, turn to the network tab, the response header displayed in the list was still 'text/html'.

I try to enable the Network Service in chrome://flags, the issue comes again, the modification of response header doesn't work.
Only if I disable the Network Service, or keep it to default, the modification of response header works, but not shown in the network tab.
POC:
chrome.webRequest.onHeadersReceived.addListener(details => {
  details.responseHeaders.find(x => x.name.toLowerCase() === 'content-type').value = 'text/plain';
  return {
    responseHeaders: details.responseHeaders,
  };
}, {urls: ["<all_urls>"]}, ["responseHeaders", "blocking"]);
Components: Internals>Services>Network
Mergedinto: 827582
Status: Duplicate (was: Unconfirmed)
Thanks for confirming!

Modifying the headers not working with Network Service enabled is  Issue 827582 .

For the solution see https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/vYIaeezZwfQ.

(You need to add the "extraHeaders" option).

Sign in to add a comment