question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Accept" header appears to be overridden using setExtraHTTPHeaders, but isn't

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.14.0
  • Platform / OS version: Laravel Homestead/Ubuntu 4.4.0-66-generic #87
  • URLs (if applicable):
  • Node.js version: v11.13.0

What steps will reproduce the problem?

await eloquaPage.setExtraHTTPHeaders(
        {
            'Accept': 'application/json' // also tried 'accept', accept, Accept, "accept", "Accept"
        });
// let thisResponse = await page.goto(<url>);
// console.log(thisResponse.request().headers()); <= shows the overridden header, as expected

What is the expected result? Accept => javascript/json

What happens instead? (as logged in a php built-in test server) [accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3

I am able to overwrite other headers, and add new headers. If I am doing something wrong, please let me know. I see https://github.com/GoogleChrome/puppeteer/issues/3638 but it was closed without a resolution that I can see.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

4reactions
mkirkland4874commented, Aug 9, 2019

I get the same error. This is how I got around it:

await page.setRequestInterception(true);
page.on('request', request => {
  const headers = Object.assign({}, request.headers(), {
    accept: 'application/json',
  });
  request.continue({headers}); // Works
});

const headers = { 'accept': 'application/json' };
await page.setExtraHTTPHeaders(headers); // Does not work
3reactions
panthonycommented, Oct 10, 2019

Not sure if related or not but is that the reason why accept, accept-language and accept-encoding do not appears when you call request.headers()?

I’d like to know which headers where sent but the return of this methods seems incomplete…

Read more comments on GitHub >

github_iconTop Results From Across the Web

849972 - DevTools: Headers overridden with Network ...
Issue 849972: DevTools: Headers overridden with Network.setExtraHTTPHeaders are selectively munged/ignored by the browser.
Read more >
URLRequest with Accept header: gets put in request body, not ...
Namely on community.adobe.com , but the requests from SWF there are accompanied both by the Accept header and the POST parameter indicating the ......
Read more >
Modifying Headers In HTTP(s) Requests In UI Automation ...
The ability to modify the headers of traffic that pass through your browser is a great tool to have. Besides overriding X-frame-options ,...
Read more >
Troubleshooting a failed canary - Amazon CloudWatch
Modifying the request headers by adding a trace header or adding extra headers using Puppeteer's page.setExtraHTTPHeaders causes a CORS check for ...
Read more >
BrowserContext | Playwright - CukeTest
If a page opens another page, e.g. with a window.open call, the popup will belong to the parent page's browser context. Playwright allows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found