File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -1409,6 +1409,10 @@ and will throw an error.
14091409#### ` http2stream.respond([headers[, options]]) `
14101410<!-- YAML
14111411added: v8.4.0
1412+ changes:
1413+ - version: REPLACEME
1414+ pr-url: https://github.com/nodejs/node/pull/33160
1415+ description: Allow explicity setting date headers.
14121416-->
14131417
14141418* ` headers ` {HTTP/2 Headers Object}
@@ -1453,6 +1457,9 @@ server.on('stream', (stream) => {
14531457<!-- YAML
14541458added: v8.4.0
14551459changes:
1460+ - version: REPLACEME
1461+ pr-url: https://github.com/nodejs/node/pull/33160
1462+ description: Allow explicity setting date headers.
14561463 - version: v12.12.0
14571464 pr-url: https://github.com/nodejs/node/pull/29876
14581465 description: The `fd` option may now be a `FileHandle`.
@@ -1551,6 +1558,9 @@ server.on('stream', (stream) => {
15511558<!-- YAML
15521559added: v8.4.0
15531560changes:
1561+ - version: REPLACEME
1562+ pr-url: https://github.com/nodejs/node/pull/33160
1563+ description: Allow explicity setting date headers.
15541564 - version: v10.0.0
15551565 pr-url: https://github.com/nodejs/node/pull/18936
15561566 description: Any readable file, not necessarily a
Original file line number Diff line number Diff line change @@ -2222,7 +2222,10 @@ function processHeaders(oldHeaders) {
22222222 const statusCode =
22232223 headers [ HTTP2_HEADER_STATUS ] =
22242224 headers [ HTTP2_HEADER_STATUS ] | 0 || HTTP_STATUS_OK ;
2225- headers [ HTTP2_HEADER_DATE ] = utcDate ( ) ;
2225+
2226+ if ( headers [ HTTP2_HEADER_DATE ] === null ||
2227+ headers [ HTTP2_HEADER_DATE ] === undefined )
2228+ headers [ HTTP2_HEADER_DATE ] = utcDate ( ) ;
22262229
22272230 // This is intentionally stricter than the HTTP/1 implementation, which
22282231 // allows values between 100 and 999 (inclusive) in order to allow for
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ if ( ! common . hasCrypto ) { common . skip ( 'missing crypto' ) ; }
4+ const assert = require ( 'assert' ) ;
5+ const http2 = require ( 'http2' ) ;
6+
7+ const server = http2 . createServer ( common . mustCall ( ( request , response ) => {
8+ response . setHeader ( 'date' , 'snacks o clock' ) ;
9+ response . end ( ) ;
10+ } ) ) ;
11+
12+ server . listen ( 0 , common . mustCall ( ( ) => {
13+ const session = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
14+ const req = session . request ( ) ;
15+ req . on ( 'response' , ( headers , flags ) => {
16+ assert . deepStrictEqual ( headers . date , 'snacks o clock' ) ;
17+ } ) ;
18+ req . on ( 'end' , ( ) => {
19+ session . close ( ) ;
20+ server . close ( ) ;
21+ } ) ;
22+ } ) ) ;
You can’t perform that action at this time.
0 commit comments