puppeteer: page.setExtraHTTPHeaders cause 'ERR_INVALID_ARGUMENT' error
Steps to reproduce
Tell us about your environment:
- Puppeteer version: 1.20.0
- Platform / OS version: mac OS
- URLs (if applicable):
- Node.js version: v11.11.0
What steps will reproduce the problem?
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: false,
ignoreHTTPSErrors: true,
ignoreDefaultArgs: ["--enable-automation"],
args: [
'–no-sandbox',
]
});
const page = await browser.newPage();
await page.setExtraHTTPHeaders(
{'proxy-authorization': 'test'}
);
await page.goto('http://example.com/');
await page.waitFor(10000);
await browser.close();
})();
What is the expected result? go to the url success
What happens instead?
(node:86672) UnhandledPromiseRejectionWarning: Error: net::ERR_INVALID_ARGUMENT at http://example.com/
at navigate (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/FrameManager.js:120:37)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
-- ASYNC --
at Frame.<anonymous> (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/helper.js:111:15)
at Page.goto (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/Page.js:674:49)
at Page.<anonymous> (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/helper.js:112:23)
at /Users/andrew/Documents/otherProject/vs/demo/demo.js:16:16
at processTicksAndRejections (internal/process/next_tick.js:81:5)
But, if I replace header proxy-authorization
to proxyauthorization
, it’s fine.
So,it seems that it’s not allowed containing ‘-’ in header, is this corrent? Or is it an issue?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 16
We’re getting the same
ERR_INVALID_ARGUMENT
error when setting aHost
header viapage.setExtraHTTPHeaders()
and loadinghttp://localhost/path/to/tested/page
. When I curl it, I get the response I expect:Using
v2.0.0
.I wonder if setting (resetting?) some headers is bad?
https://github.com/chromium/chromium/blob/b2254b38369f4f8ce8685b7a82dee1251f6cea22/services/network/url_loader.cc#L679-L683
https://github.com/chromium/chromium/blob/3611052c055897e5ebbc5b73ea295092e0c20141/services/network/public/cpp/header_util_unittest.cc#L50
If you want to pass proxy-authorization then use below code instead of
page.setExtraHTTPHeaders()
:await page.authenticate({username:'', password:''})