File tree Expand file tree Collapse file tree 12 files changed +72
-4
lines changed
Expand file tree Collapse file tree 12 files changed +72
-4
lines changed Original file line number Diff line number Diff line change @@ -1615,7 +1615,7 @@ declare module "http" {
16151615 createConnection (
16161616 options : ClientRequestArgs ,
16171617 callback ?: ( err : Error | null , stream : stream . Duplex ) => void ,
1618- ) : stream . Duplex ;
1618+ ) : stream . Duplex | null | undefined ;
16191619 /**
16201620 * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
16211621 *
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ declare module "https" {
3232 class Agent extends http . Agent {
3333 constructor ( options ?: AgentOptions ) ;
3434 options : AgentOptions ;
35+ createConnection (
36+ options : RequestOptions ,
37+ callback ?: ( err : Error | null , stream : Duplex ) => void ,
38+ ) : Duplex | null | undefined ;
39+ getName ( options ?: RequestOptions ) : string ;
3540 }
3641 interface Server <
3742 Request extends typeof http . IncomingMessage = typeof http . IncomingMessage ,
Original file line number Diff line number Diff line change @@ -22,6 +22,18 @@ import * as url from "node:url";
2222
2323 agent = https . globalAgent ;
2424
25+ class CustomAgent extends https . Agent {
26+ createConnection ( options : https . RequestOptions , callback ?: ( err : Error | null , socket : net . Socket ) => void ) {
27+ const socket = new net . Socket ( options ) ;
28+ callback ?.( null , socket ) ;
29+ return socket ;
30+ }
31+ getName ( options : https . RequestOptions ) {
32+ return `${ super . getName ( options ) } :${ options ?. ca } :${ options ?. cert } :${ options ?. key } ` ;
33+ }
34+ }
35+ agent = new CustomAgent ( ) ;
36+
2537 let sockets : NodeJS . ReadOnlyDict < net . Socket [ ] > = agent . sockets ;
2638 sockets = agent . freeSockets ;
2739
Original file line number Diff line number Diff line change @@ -1559,7 +1559,7 @@ declare module "http" {
15591559 createConnection (
15601560 options : ClientRequestArgs ,
15611561 callback ?: ( err : Error | null , stream : stream . Duplex ) => void ,
1562- ) : stream . Duplex ;
1562+ ) : stream . Duplex | null | undefined ;
15631563 /**
15641564 * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
15651565 *
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ declare module "https" {
3131 class Agent extends http . Agent {
3232 constructor ( options ?: AgentOptions ) ;
3333 options : AgentOptions ;
34+ createConnection (
35+ options : RequestOptions ,
36+ callback ?: ( err : Error | null , stream : Duplex ) => void ,
37+ ) : Duplex | null | undefined ;
38+ getName ( options ?: RequestOptions ) : string ;
3439 }
3540 interface Server <
3641 Request extends typeof http . IncomingMessage = typeof http . IncomingMessage ,
Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ import * as url from "node:url";
1919
2020 agent = https . globalAgent ;
2121
22+ class CustomAgent extends https . Agent {
23+ createConnection ( options : https . RequestOptions , callback ?: ( err : Error | null , socket : net . Socket ) => void ) {
24+ const socket = new net . Socket ( options ) ;
25+ callback ?.( null , socket ) ;
26+ return socket ;
27+ }
28+ getName ( options : https . RequestOptions ) {
29+ return `${ super . getName ( options ) } :${ options ?. ca } :${ options ?. cert } :${ options ?. key } ` ;
30+ }
31+ }
32+ agent = new CustomAgent ( ) ;
33+
2234 let sockets : NodeJS . ReadOnlyDict < net . Socket [ ] > = agent . sockets ;
2335 sockets = agent . freeSockets ;
2436
Original file line number Diff line number Diff line change @@ -1589,7 +1589,7 @@ declare module "http" {
15891589 createConnection (
15901590 options : ClientRequestArgs ,
15911591 callback ?: ( err : Error | null , stream : stream . Duplex ) => void ,
1592- ) : stream . Duplex ;
1592+ ) : stream . Duplex | null | undefined ;
15931593 /**
15941594 * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
15951595 *
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ declare module "https" {
3131 class Agent extends http . Agent {
3232 constructor ( options ?: AgentOptions ) ;
3333 options : AgentOptions ;
34+ createConnection (
35+ options : RequestOptions ,
36+ callback ?: ( err : Error | null , stream : Duplex ) => void ,
37+ ) : Duplex | null | undefined ;
38+ getName ( options ?: RequestOptions ) : string ;
3439 }
3540 interface Server <
3641 Request extends typeof http . IncomingMessage = typeof http . IncomingMessage ,
Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ import * as url from "node:url";
1919
2020 agent = https . globalAgent ;
2121
22+ class CustomAgent extends https . Agent {
23+ createConnection ( options : https . RequestOptions , callback ?: ( err : Error | null , socket : net . Socket ) => void ) {
24+ const socket = new net . Socket ( options ) ;
25+ callback ?.( null , socket ) ;
26+ return socket ;
27+ }
28+ getName ( options : https . RequestOptions ) {
29+ return `${ super . getName ( options ) } :${ options ?. ca } :${ options ?. cert } :${ options ?. key } ` ;
30+ }
31+ }
32+ agent = new CustomAgent ( ) ;
33+
2234 let sockets : NodeJS . ReadOnlyDict < net . Socket [ ] > = agent . sockets ;
2335 sockets = agent . freeSockets ;
2436
Original file line number Diff line number Diff line change @@ -1591,7 +1591,7 @@ declare module "http" {
15911591 createConnection (
15921592 options : ClientRequestArgs ,
15931593 callback ?: ( err : Error | null , stream : stream . Duplex ) => void ,
1594- ) : stream . Duplex ;
1594+ ) : stream . Duplex | null | undefined ;
15951595 /**
15961596 * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
15971597 *
You can’t perform that action at this time.
0 commit comments