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.

page.on('request') doesn't take header overrides into account when processing redirects (301/302)

See original GitHub issue

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

const browser = await puppeteer.launch();

const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('response', (response) => {
  console.log('RESPONSE RECEIVED');
  console.log(response.status + ' ' + response.url);
});
page.on('request', (request) => {
 console.log('REQUEST RECEIVED');
  console.log(request.url);

  request.continue({headers: {'test-header': 'dummy-value'}});
});

await page.goto('http://www.mocky.io/v2/5a427066300000821d709e0f');
//await page.goto('https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending');

await page.screenshot({path: 'screenshot.png', fullPage: true});

await browser.close();

I’ve included the following minimal puppeteer code and 2 sample urls. https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending which is a basic page that returns the HTTP headers sent in the request. And http://www.mocky.io/v2/5a427066300000821d709e0f which returns a 302 to the url specified above.

What is the expected result? Puppeteer should send my custom header in both cases.

What happens instead? Puppeteer doesn’t send the custom header in the request that follows the 301/302. Even though the onRequest event is fired for both the 301 request and the followup request.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
Glennvdcommented, Mar 20, 2018

FYI this has been fixed in the latest master chromium builds when using --enable-features=NetworkService, in case this is a blocking issue for anyone else.

1reaction
aslushnikovcommented, Dec 28, 2017

Thanks @Glennvd @yujiosaka for the investigation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

page.on('request') doesn't take header overrides into account when ...
page.on('request') doesn't take header overrides into account when processing redirects (301/302)
Read more >
How to manage a redirect request after a jQuery Ajax call
I perform an AJAX request that has 2 possible responses: one that redirects the browser to a new page and one that replaces...
Read more >
8. Actions Files - Privoxy
The list of actions files to be used are defined in the main configuration file, and are processed in the order they are...
Read more >
HTTP/1.1: Header Field Definitions
The directives specify behavior intended to prevent caches from adversely interfering with the request or response. These directives typically override the ...
Read more >
Request Options - Guzzle Documentation
Note: When tracking redirects the X-Guzzle-Redirect-History header will exclude ... Pass an array of HTTP authentication parameters to use with the request.
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