set Host header using `setExtraHTTPHeaders` `net::ERR_INVALID_ARGUMENT`
See original GitHub issueSteps to reproduce
- Puppeteer version: 5.0.0
What steps will reproduce the problem?
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--headless',
'--disable-gpu',
'--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0'
]
});
await new Promise(resolve => setTimeout(resolve, 5000));
const page = await browser.newPage();
await page.setExtraHTTPHeaders({'Host': 'bukdjango_captcha.com'})
await page.goto('http://bukdjango_captcha.com:8000/recaptcha_v3');
await page.screenshot({path: 'example.png'});
console.log(await page.content())
await browser.close();
})();
What is the expected result? I can override host header.
What happens instead?
tests_browser_1 | (node:1) UnhandledPromiseRejectionWarning: Error: net::ERR_INVALID_ARGUMENT at http://bukdjango_captcha.com:8000/recaptcha_v3
tests_browser_1 | at navigate (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:96:23)
tests_browser_1 | at processTicksAndRejections (internal/process/task_queues.js:93:5)
tests_browser_1 | at async FrameManager.navigateFrame (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:71:21)
tests_browser_1 | at async Frame.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/FrameManager.js:296:16)
tests_browser_1 | at async Page.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/Page.js:749:16)
tests_browser_1 | at async /dockertestapp/test.js:16:3
tests_browser_1 | -- ASYNC --
tests_browser_1 | at Frame.<anonymous> (/dockertestapp/node_modules/puppeteer/lib/cjs/common/helper.js:109:19)
tests_browser_1 | at Page.goto (/dockertestapp/node_modules/puppeteer/lib/cjs/common/Page.js:749:53)
tests_browser_1 | at Page.<anonymous> (/dockertestapp/node_modules/puppeteer/lib/cjs/common/helper.js:110:27)
tests_browser_1 | at /dockertestapp/test.js:16:14
tests_browser_1 | at processTicksAndRejections (internal/process/task_queues.js:93:5)
tests_browser_1 | (Use `node --trace-warnings ...` to show where the warning was created)
tests_browser_1 | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise whi
ch was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (r
ejection id: 1)
tests_browser_1 | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exi
t code.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:17
Top Results From Across the Web
795336 - Can't set Host: headers via Chrome DevTools ...
Issue 795336: Can't set Host: headers via Chrome DevTools "Network.setExtraHTTPHeaders" anymore. Reported by schedule max.m.
Read more >How do I set multiple custom HTTP headers in puppeteer?
You are able to set multiple HTTP headers with the dedicated puppeteer method: page.setExtraHTTPHeaders as well. E.g.: await page.
Read more >Host - HTTP - MDN Web Docs
The Host request header specifies the host and port number of the server to which the request is being sent.
Read more >SetExtraHTTPHeaders - Headless - Google Groups
I am working with Headless Chromium and am attempting to add a cookie to the HTTP request header using network::SetExtraHTTPHeaders.
Read more >Page.setExtraHTTPHeaders() method - Puppeteer
headers, Record<string, string>, An object containing additional HTTP headers to be sent with every request. All header values must be strings.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got same problem with chromedp on Golang.Did you find any sollution yet?
already tried… didnt work