@@ -7843,6 +7843,87 @@ var require_pool_base = __commonJS({
78437843 }
78447844} ) ;
78457845
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+
78467927// lib/core/request.js
78477928var require_request2 = __commonJS ( {
78487929 "lib/core/request.js" ( exports2 , module2 ) {
@@ -8051,9 +8132,11 @@ var require_request2 = __commonJS({
80518132 }
80528133 } ;
80538134 function processHeaderValue ( key , val ) {
8054- if ( val && ( typeof val === "object" && ! Array . isArray ( val ) ) ) {
8135+ if ( val && typeof val === "object" ) {
80558136 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 ) {
80578140 throw new InvalidArgumentError ( `invalid ${ key } header` ) ;
80588141 }
80598142 return `${ key } : ${ val } \r
@@ -8204,6 +8287,10 @@ var require_connect = __commonJS({
82048287 host : hostname
82058288 } ) ;
82068289 }
8290+ if ( options . keepAlive == null || options . keepAlive ) {
8291+ const keepAliveInitialDelay = options . keepAliveInitialDelay === void 0 ? 6e4 : options . keepAliveInitialDelay ;
8292+ socket . setKeepAlive ( true , keepAliveInitialDelay ) ;
8293+ }
82078294 const cancelTimeout = setupTimeout ( ( ) => onConnectTimeout ( socket ) , timeout ) ;
82088295 socket . setNoDelay ( true ) . once ( protocol === "https:" ? "secureConnect" : "connect" , function ( ) {
82098296 cancelTimeout ( ) ;
@@ -8774,6 +8861,7 @@ var require_client = __commonJS({
87748861 var assert = require ( "assert" ) ;
87758862 var net = require ( "net" ) ;
87768863 var util = require_util ( ) ;
8864+ var timers = require_timers ( ) ;
87778865 var Request = require_request2 ( ) ;
87788866 var DispatcherBase = require_dispatcher_base ( ) ;
87798867 var {
@@ -9130,9 +9218,9 @@ var require_client = __commonJS({
91309218 setTimeout ( value , type ) {
91319219 this . timeoutType = type ;
91329220 if ( value !== this . timeoutValue ) {
9133- clearTimeout ( this . timeout ) ;
9221+ timers . clearTimeout ( this . timeout ) ;
91349222 if ( value ) {
9135- this . timeout = setTimeout ( onParserTimeout , value , this ) ;
9223+ this . timeout = timers . setTimeout ( onParserTimeout , value , this ) ;
91369224 if ( this . timeout . unref ) {
91379225 this . timeout . unref ( ) ;
91389226 }
@@ -9221,7 +9309,7 @@ var require_client = __commonJS({
92219309 assert ( currentParser == null ) ;
92229310 this . llhttp . llhttp_free ( this . ptr ) ;
92239311 this . ptr = null ;
9224- clearTimeout ( this . timeout ) ;
9312+ timers . clearTimeout ( this . timeout ) ;
92259313 this . timeout = null ;
92269314 this . timeoutValue = null ;
92279315 this . timeoutType = null ;
0 commit comments