File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const debug = createDebug('https-proxy-agent:agent');
2727export 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` ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments