mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: add Host header when used with http_proxy (#10080)
Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
parent
e02a3cf6e4
commit
edbfff7b04
@ -61,6 +61,8 @@ export function httpRequest(
|
||||
options.hostname = proxy.hostname;
|
||||
options.protocol = proxy.protocol;
|
||||
options.port = proxy.port;
|
||||
options.headers ??= {};
|
||||
options.headers['Host'] ||= url.host;
|
||||
} else {
|
||||
options.agent = createHttpsProxyAgent({
|
||||
host: proxy.host,
|
||||
|
@ -136,9 +136,11 @@ describe('Chrome install', () => {
|
||||
const proxyUrl = new URL(`http://localhost:54321`);
|
||||
let proxyServer: http.Server;
|
||||
let proxiedRequestUrls: string[] = [];
|
||||
let proxiedRequestHosts: string[] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
proxiedRequestUrls = [];
|
||||
proxiedRequestHosts = [];
|
||||
proxyServer = http
|
||||
.createServer(
|
||||
(
|
||||
@ -164,6 +166,7 @@ describe('Chrome install', () => {
|
||||
);
|
||||
originalRequest.pipe(proxyRequest, {end: true});
|
||||
proxiedRequestUrls.push(url);
|
||||
proxiedRequestHosts.push(originalRequest.headers?.host || '');
|
||||
}
|
||||
)
|
||||
.listen({
|
||||
@ -203,6 +206,9 @@ describe('Chrome install', () => {
|
||||
assert.deepStrictEqual(proxiedRequestUrls, [
|
||||
getServerUrl() + '/113.0.5672.0/linux64/chrome-linux64.zip',
|
||||
]);
|
||||
assert.deepStrictEqual(proxiedRequestHosts, [
|
||||
getServerUrl().replace('http://', ''),
|
||||
]);
|
||||
});
|
||||
|
||||
it('can download via a proxy', async function () {
|
||||
@ -225,6 +231,9 @@ describe('Chrome install', () => {
|
||||
assert.deepStrictEqual(proxiedRequestUrls, [
|
||||
getServerUrl() + '/113.0.5672.0/linux64/chrome-linux64.zip',
|
||||
]);
|
||||
assert.deepStrictEqual(proxiedRequestHosts, [
|
||||
getServerUrl().replace('http://', ''),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user