@@ -7843,6 +7843,87 @@ var require_pool_base = __commonJS({
7843
7843
}
7844
7844
} ) ;
7845
7845
7846
+ // lib/timers.js
7847
+ var require_timers = __commonJS ( {
7848
+ "lib/timers.js" ( exports2 , module2 ) {
7849
+ "use strict" ;
7850
+ var fastNow = Date . now ( ) ;
7851
+ var fastNowTimeout ;
7852
+ var fastTimers = [ ] ;
7853
+ function onTimeout ( ) {
7854
+ fastNow = Date . now ( ) ;
7855
+ let len = fastTimers . length ;
7856
+ let idx = 0 ;
7857
+ while ( idx < len ) {
7858
+ const timer = fastTimers [ idx ] ;
7859
+ if ( timer . expires && fastNow >= timer . expires ) {
7860
+ timer . expires = 0 ;
7861
+ timer . callback ( timer . opaque ) ;
7862
+ }
7863
+ if ( timer . expires === 0 ) {
7864
+ timer . active = false ;
7865
+ if ( idx !== len - 1 ) {
7866
+ fastTimers [ idx ] = fastTimers . pop ( ) ;
7867
+ } else {
7868
+ fastTimers . pop ( ) ;
7869
+ }
7870
+ len -= 1 ;
7871
+ } else {
7872
+ idx += 1 ;
7873
+ }
7874
+ }
7875
+ if ( fastTimers . length > 0 ) {
7876
+ refreshTimeout ( ) ;
7877
+ }
7878
+ }
7879
+ function refreshTimeout ( ) {
7880
+ if ( fastNowTimeout && fastNowTimeout . refresh ) {
7881
+ fastNowTimeout . refresh ( ) ;
7882
+ } else {
7883
+ clearTimeout ( fastNowTimeout ) ;
7884
+ fastNowTimeout = setTimeout ( onTimeout , 1e3 ) ;
7885
+ if ( fastNowTimeout . unref ) {
7886
+ fastNowTimeout . unref ( ) ;
7887
+ }
7888
+ }
7889
+ }
7890
+ var Timeout = class {
7891
+ constructor ( callback , delay , opaque ) {
7892
+ this . callback = callback ;
7893
+ this . delay = delay ;
7894
+ this . opaque = opaque ;
7895
+ this . expires = 0 ;
7896
+ this . active = false ;
7897
+ this . refresh ( ) ;
7898
+ }
7899
+ refresh ( ) {
7900
+ if ( ! this . active ) {
7901
+ this . active = true ;
7902
+ fastTimers . push ( this ) ;
7903
+ if ( ! fastNowTimeout || fastTimers . length === 1 ) {
7904
+ refreshTimeout ( ) ;
7905
+ fastNow = Date . now ( ) ;
7906
+ }
7907
+ }
7908
+ this . expires = fastNow + this . delay ;
7909
+ }
7910
+ clear ( ) {
7911
+ this . expires = 0 ;
7912
+ }
7913
+ } ;
7914
+ module2 . exports = {
7915
+ setTimeout ( callback , delay , opaque ) {
7916
+ return new Timeout ( callback , delay , opaque ) ;
7917
+ } ,
7918
+ clearTimeout ( timeout ) {
7919
+ if ( timeout && timeout . clear ) {
7920
+ timeout . clear ( ) ;
7921
+ }
7922
+ }
7923
+ } ;
7924
+ }
7925
+ } ) ;
7926
+
7846
7927
// lib/core/request.js
7847
7928
var require_request2 = __commonJS ( {
7848
7929
"lib/core/request.js" ( exports2 , module2 ) {
@@ -8051,9 +8132,11 @@ var require_request2 = __commonJS({
8051
8132
}
8052
8133
} ;
8053
8134
function processHeaderValue ( key , val ) {
8054
- if ( val && ( typeof val === "object" && ! Array . isArray ( val ) ) ) {
8135
+ if ( val && typeof val === "object" ) {
8055
8136
throw new InvalidArgumentError ( `invalid ${ key } header` ) ;
8056
- } else if ( headerCharRegex . exec ( val ) !== null ) {
8137
+ }
8138
+ val = val != null ? `${ val } ` : "" ;
8139
+ if ( headerCharRegex . exec ( val ) !== null ) {
8057
8140
throw new InvalidArgumentError ( `invalid ${ key } header` ) ;
8058
8141
}
8059
8142
return `${ key } : ${ val } \r
@@ -8204,6 +8287,10 @@ var require_connect = __commonJS({
8204
8287
host : hostname
8205
8288
} ) ;
8206
8289
}
8290
+ if ( options . keepAlive == null || options . keepAlive ) {
8291
+ const keepAliveInitialDelay = options . keepAliveInitialDelay === void 0 ? 6e4 : options . keepAliveInitialDelay ;
8292
+ socket . setKeepAlive ( true , keepAliveInitialDelay ) ;
8293
+ }
8207
8294
const cancelTimeout = setupTimeout ( ( ) => onConnectTimeout ( socket ) , timeout ) ;
8208
8295
socket . setNoDelay ( true ) . once ( protocol === "https:" ? "secureConnect" : "connect" , function ( ) {
8209
8296
cancelTimeout ( ) ;
@@ -8774,6 +8861,7 @@ var require_client = __commonJS({
8774
8861
var assert = require ( "assert" ) ;
8775
8862
var net = require ( "net" ) ;
8776
8863
var util = require_util ( ) ;
8864
+ var timers = require_timers ( ) ;
8777
8865
var Request = require_request2 ( ) ;
8778
8866
var DispatcherBase = require_dispatcher_base ( ) ;
8779
8867
var {
@@ -9130,9 +9218,9 @@ var require_client = __commonJS({
9130
9218
setTimeout ( value , type ) {
9131
9219
this . timeoutType = type ;
9132
9220
if ( value !== this . timeoutValue ) {
9133
- clearTimeout ( this . timeout ) ;
9221
+ timers . clearTimeout ( this . timeout ) ;
9134
9222
if ( value ) {
9135
- this . timeout = setTimeout ( onParserTimeout , value , this ) ;
9223
+ this . timeout = timers . setTimeout ( onParserTimeout , value , this ) ;
9136
9224
if ( this . timeout . unref ) {
9137
9225
this . timeout . unref ( ) ;
9138
9226
}
@@ -9221,7 +9309,7 @@ var require_client = __commonJS({
9221
9309
assert ( currentParser == null ) ;
9222
9310
this . llhttp . llhttp_free ( this . ptr ) ;
9223
9311
this . ptr = null ;
9224
- clearTimeout ( this . timeout ) ;
9312
+ timers . clearTimeout ( this . timeout ) ;
9225
9313
this . timeout = null ;
9226
9314
this . timeoutValue = null ;
9227
9315
this . timeoutType = null ;
0 commit comments