@@ -2565,7 +2565,7 @@ function prepareResponseHeaders(stream, headersParam, options) {
25652565}
25662566
25672567function prepareResponseHeadersObject ( oldHeaders , options ) {
2568- assertIsObject ( oldHeaders , 'headers' ) ;
2568+ assertIsObject ( oldHeaders , 'headers' , [ 'Object' , 'Array' ] ) ;
25692569 const headers = { __proto__ : null } ;
25702570
25712571 if ( oldHeaders !== null && oldHeaders !== undefined ) {
@@ -2586,18 +2586,7 @@ function prepareResponseHeadersObject(oldHeaders, options) {
25862586 headers [ HTTP2_HEADER_DATE ] ??= utcDate ( ) ;
25872587 }
25882588
2589- // This is intentionally stricter than the HTTP/1 implementation, which
2590- // allows values between 100 and 999 (inclusive) in order to allow for
2591- // backwards compatibility with non-spec compliant code. With HTTP/2,
2592- // we have the opportunity to start fresh with stricter spec compliance.
2593- // This will have an impact on the compatibility layer for anyone using
2594- // non-standard, non-compliant status codes.
2595- if ( statusCode < 200 || statusCode > 599 )
2596- throw new ERR_HTTP2_STATUS_INVALID ( headers [ HTTP2_HEADER_STATUS ] ) ;
2597-
2598- const neverIndex = headers [ kSensitiveHeaders ] ;
2599- if ( neverIndex !== undefined && ! ArrayIsArray ( neverIndex ) )
2600- throw new ERR_INVALID_ARG_VALUE ( 'headers[http2.neverIndex]' , neverIndex ) ;
2589+ validatePreparedResponseHeaders ( headers , statusCode ) ;
26012590
26022591 return {
26032592 headers,
@@ -2629,6 +2618,12 @@ function prepareResponseHeadersArray(headers, options) {
26292618 headers . push ( HTTP2_HEADER_DATE , utcDate ( ) ) ;
26302619 }
26312620
2621+ validatePreparedResponseHeaders ( headers , statusCode ) ;
2622+
2623+ return { headers, statusCode } ;
2624+ }
2625+
2626+ function validatePreparedResponseHeaders ( headers , statusCode ) {
26322627 // This is intentionally stricter than the HTTP/1 implementation, which
26332628 // allows values between 100 and 999 (inclusive) in order to allow for
26342629 // backwards compatibility with non-spec compliant code. With HTTP/2,
@@ -2641,8 +2636,6 @@ function prepareResponseHeadersArray(headers, options) {
26412636 const neverIndex = headers [ kSensitiveHeaders ] ;
26422637 if ( neverIndex !== undefined && ! ArrayIsArray ( neverIndex ) )
26432638 throw new ERR_INVALID_ARG_VALUE ( 'headers[http2.neverIndex]' , neverIndex ) ;
2644-
2645- return { headers, statusCode } ;
26462639}
26472640
26482641function onFileUnpipe ( ) {
0 commit comments