Skip to content

Commit a015873

Browse files
committed
Merge pr TooTallNate#96 with minor change
1 parent fc2e773 commit a015873

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/agent.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const debug = createDebug('https-proxy-agent:agent');
2727
export default class HttpsProxyAgent extends Agent {
2828
private secureProxy: boolean;
2929
private proxy: HttpsProxyAgentOptions;
30+
public timeout: number | null;
3031

3132
constructor(_opts: string | HttpsProxyAgentOptions) {
3233
let opts: HttpsProxyAgentOptions;
@@ -43,6 +44,8 @@ export default class HttpsProxyAgent extends Agent {
4344
debug('creating new HttpsProxyAgent instance: %o', opts);
4445
super(opts);
4546

47+
this.timeout = opts.timeout || null;
48+
4649
const proxy: HttpsProxyAgentOptions = { ...opts };
4750

4851
// If `true`, then connect to the proxy server over TLS.
@@ -98,6 +101,10 @@ export default class HttpsProxyAgent extends Agent {
98101
socket = net.connect(proxy as net.NetConnectOpts);
99102
}
100103

104+
if (this.timeout) {
105+
socket.setTimeout(this.timeout);
106+
}
107+
101108
const headers: OutgoingHttpHeaders = { ...proxy.headers };
102109
const hostname = `${opts.host}:${opts.port}`;
103110
let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace createHttpsProxyAgent {
1818
host?: string | null;
1919
path?: string | null;
2020
port?: string | number | null;
21+
timeout?: number;
2122
}
2223

2324
export interface HttpsProxyAgentOptions

0 commit comments

Comments
 (0)