7
7
ArrayIsArray,
8
8
ArrayPrototypeForEach,
9
9
ArrayPrototypePush,
10
+ ArrayPrototypeUnshift,
10
11
FunctionPrototypeBind,
11
12
FunctionPrototypeCall,
12
13
MathMin,
@@ -20,6 +21,7 @@ const {
20
21
ReflectApply,
21
22
ReflectGetPrototypeOf,
22
23
RegExpPrototypeTest,
24
+ SafeArrayIterator,
23
25
SafeMap,
24
26
SafeSet,
25
27
StringPrototypeSlice,
@@ -187,21 +189,22 @@ let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {
187
189
// this seems pretty fast, though.
188
190
function debugStream ( id , sessionType , message , ...args ) {
189
191
debug ( 'Http2Stream %s [Http2Session %s]: ' + message ,
190
- id , sessionName ( sessionType ) , ...args ) ;
192
+ id , sessionName ( sessionType ) , ...new SafeArrayIterator ( args ) ) ;
191
193
}
192
194
193
195
function debugStreamObj ( stream , message , ...args ) {
194
196
const session = stream [ kSession ] ;
195
197
const type = session ? session [ kType ] : undefined ;
196
- debugStream ( stream [ kID ] , type , message , ...args ) ;
198
+ debugStream ( stream [ kID ] , type , message , ...new SafeArrayIterator ( args ) ) ;
197
199
}
198
200
199
201
function debugSession ( sessionType , message , ...args ) {
200
- debug ( 'Http2Session %s: ' + message , sessionName ( sessionType ) , ...args ) ;
202
+ debug ( 'Http2Session %s: ' + message , sessionName ( sessionType ) ,
203
+ ...new SafeArrayIterator ( args ) ) ;
201
204
}
202
205
203
206
function debugSessionObj ( session , message , ...args ) {
204
- debugSession ( session [ kType ] , message , ...args ) ;
207
+ debugSession ( session [ kType ] , message , ...new SafeArrayIterator ( args ) ) ;
205
208
}
206
209
207
210
const kMaxFrameSize = ( 2 ** 24 ) - 1 ;
@@ -317,7 +320,7 @@ const SESSION_FLAGS_DESTROYED = 0x4;
317
320
318
321
// Top level to avoid creating a closure
319
322
function emit ( self , ...args ) {
320
- self . emit ( ... args ) ;
323
+ ReflectApply ( self . emit , self , args ) ;
321
324
}
322
325
323
326
// Called when a new block of headers has been received for a given
@@ -1020,7 +1023,7 @@ function setupHandle(socket, type, options) {
1020
1023
1021
1024
if ( type === NGHTTP2_SESSION_SERVER &&
1022
1025
ArrayIsArray ( options . origins ) ) {
1023
- this . origin ( ... options . origins ) ;
1026
+ ReflectApply ( this . origin , this , options . origins ) ;
1024
1027
}
1025
1028
1026
1029
process . nextTick ( emit , this , 'connect' , this , socket ) ;
@@ -1495,7 +1498,7 @@ class Http2Session extends EventEmitter {
1495
1498
[ EventEmitter . captureRejectionSymbol ] ( err , event , ...args ) {
1496
1499
switch ( event ) {
1497
1500
case 'stream' :
1498
- const [ stream ] = args ;
1501
+ const stream = args [ 0 ] ;
1499
1502
stream . destroy ( err ) ;
1500
1503
break ;
1501
1504
default :
@@ -1663,7 +1666,9 @@ class ClientHttp2Session extends Http2Session {
1663
1666
this [ kUpdateTimer ] ( ) ;
1664
1667
1665
1668
if ( headers !== null && headers !== undefined ) {
1666
- for ( const header of ObjectKeys ( headers ) ) {
1669
+ const keys = ObjectKeys ( headers ) ;
1670
+ for ( let i = 0 ; i < keys . length ; i ++ ) {
1671
+ const header = keys [ i ] ;
1667
1672
if ( header [ 0 ] === ':' ) {
1668
1673
assertValidPseudoHeader ( header ) ;
1669
1674
} else if ( header && ! checkIsHttpToken ( header ) )
@@ -3095,7 +3100,7 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function(
3095
3100
case 'stream' :
3096
3101
// TODO(mcollina): we might want to match this with what we do on
3097
3102
// the compat side.
3098
- const [ stream ] = args ;
3103
+ const { 0 : stream } = args ;
3099
3104
if ( stream . sentHeaders ) {
3100
3105
stream . destroy ( err ) ;
3101
3106
} else {
@@ -3104,7 +3109,7 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function(
3104
3109
}
3105
3110
break ;
3106
3111
case 'request' :
3107
- const [ , res ] = args ;
3112
+ const { 1 : res } = args ;
3108
3113
if ( ! res . headersSent && ! res . finished ) {
3109
3114
// Don't leak headers.
3110
3115
for ( const name of res . getHeaderNames ( ) ) {
@@ -3117,8 +3122,9 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function(
3117
3122
}
3118
3123
break ;
3119
3124
default :
3125
+ ArrayPrototypeUnshift ( args , err , event ) ;
3120
3126
ReflectApply ( net . Server . prototype [ EventEmitter . captureRejectionSymbol ] ,
3121
- this , [ err , event , ... args ] ) ;
3127
+ this , args ) ;
3122
3128
}
3123
3129
} ;
3124
3130
0 commit comments