问题
Tell us about your environment:
- Puppeteer version: 1.19.0
- Platform / OS version: Debian 9
- URLs (if applicable):
- Node.js version: 8
What is the expected result?
I want override the request's host in header.
Such as a request url: http://a.com/x.jpg
. The DNS resolver may be parse the host to a slower ip address, but I know ther is a better ip like 1.2.3.4
. I want to change the url with the ip addrees and modify the host in request header.
like from curl http://a.com/x.jpg
to curl --header "Host:a.com" http://1.2.3.4/x.jpg
What happens instead?
await page.setRequestInterception(true);
page.on('request', request => {
const newHeaders = Object.assign({}, request.headers(), {
Host: 'a.com'
});
request.continue({ headers: newHeaders, url: 'http://1.2.3.4/x.jpg' });
but it doesn't work
来源:https://stackoverflow.com/questions/60539833/puppeteer-request-continue-can-not-work-with-header-host-overrided