Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net.request is losing custom headers from webRequest #27894

Closed
themadtitanmathos opened this issue Feb 24, 2021 · 4 comments
Closed

net.request is losing custom headers from webRequest #27894

themadtitanmathos opened this issue Feb 24, 2021 · 4 comments

Comments

@themadtitanmathos
Copy link

Preflight Checklist

  • [x ] I have read the Contributing Guidelines for this project.
  • [ x] I agree to follow the Code of Conduct that this project adheres to.
  • [ x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    10.1.7
  • Operating System:
    Windows 10 Enterprise 1909

When making a request with net.request, I can see (and modify) the headers received in electron.session.defaultSession.webRequest.onHeadersReceived.

electron.session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
  details.responseHeaders['my-custom-header'] = 'my-custom-value';
  callback({ responseHeaders: details.responseHeaders });
});

But by the time the net.request request.on('response') handler receives the headers, my custom header is gone.

request.on('response', (response) => {
  /* 
  response.headers === {
    // no my-custom-header present
  };
  */
});

I haven't tested if this is an issue in all types of responses, but I can tell you this is occurring without fail for the case when the response.statusCode === 200, but the response.headers.status === 304.

Expected Behavior

For net.request response handler to receive the same headers that are shipped out by webRequest.onHeadersReceived handler.

Actual Behavior

net.request response handler is receiving what seems to be a cached set of headers (or something?), which do not match what is sent out in webRequest.onHeadersReceived.

To Reproduce

  1. Find/get a response from an API where the statusCode of the response is 200, but the headers.status is 304.

  2. Modify the headers in webRequest.onHeadersReceived.

  3. Observe the headers received by net.request response handler are completely different.

@electron-triage
Copy link

Thanks for reporting this and helping to make Electron better!

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

I'm adding the blocked/needs-repro label for this reason. After you make a test case, please link to it in a followup comment.

Thanks in advance! Your help is appreciated.

@codebytere
Copy link
Member

Closing with no follow up.

@themadtitanmathos
Copy link
Author

@codebytere This will still be reachable by people looking at #27895 right? It seems very closely related.

@Mr-Wallet
Copy link

Mr-Wallet commented Mar 30, 2021

I suspect it's exactly the same problem, so multiple issues/repros are probably not necessary unless this persists after that issue is resolved. (Just my 2 cents.) You could try tweaking the standalone test case provided in that issue and confirm that it repros there; if so I guess it would be up to Electron maintainers to decide if they want to keep an eye on this separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants