Skip to content

Commit 4e0b251

Browse files
authored
fix: pass headers as object in chain (#584)
1 parent ec1ab92 commit 4e0b251

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/chain.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { getBasicAuthorizationHeader } from './utils/get_basic';
1313

1414
interface Options {
1515
method: string;
16-
headers: string[];
16+
headers: Record<string, string>;
1717
path?: string;
1818
localAddress?: string;
1919
family?: number;
@@ -71,25 +71,24 @@ export const chain = (
7171
const options: Options = {
7272
method: 'CONNECT',
7373
path: request.url,
74-
headers: [
75-
'host',
76-
request.url!,
77-
],
74+
headers: {
75+
host: request.url!,
76+
},
7877
localAddress: handlerOpts.localAddress,
7978
family: handlerOpts.ipFamily,
8079
lookup: handlerOpts.dnsLookup,
8180
};
8281

8382
if (proxy.username || proxy.password) {
84-
options.headers.push('proxy-authorization', getBasicAuthorizationHeader(proxy));
83+
options.headers['proxy-authorization'] = getBasicAuthorizationHeader(proxy);
8584
}
8685

8786
const client = proxy.protocol === 'https:'
8887
? https.request(proxy.origin, {
89-
...options as unknown as https.RequestOptions,
88+
...options,
9089
rejectUnauthorized: !handlerOpts.ignoreUpstreamProxyCertificate,
9190
})
92-
: http.request(proxy.origin, options as unknown as http.RequestOptions);
91+
: http.request(proxy.origin, options);
9392

9493
client.once('socket', (targetSocket: SocketWithPreviousStats) => {
9594
// Socket can be re-used by multiple requests.

0 commit comments

Comments
 (0)