mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
http2: do not modify explicity set date headers
Fixes: https://github.com/nodejs/node/issues/30894 Refs: https://github.com/nodejs/node/issues/29829 PR-URL: https://github.com/nodejs/node/pull/33160 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
2380d90f0a
commit
7ccb021ffc
3 files changed
+36
-1
No files matched your search
@@ -1409,6 +1409,10 @@ and will throw an error.
|
||||
#### `http2stream.respond([headers[, options]])`
|
||||
<!-- YAML
|
||||
added: v8.4.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/33160
|
||||
description: Allow explicity setting date headers.
|
||||
-->
|
||||
|
||||
* `headers` {HTTP/2 Headers Object}
|
||||
@@ -1453,6 +1457,9 @@ server.on('stream', (stream) => {
|
||||
<!-- YAML
|
||||
added: v8.4.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/33160
|
||||
description: Allow explicity setting date headers.
|
||||
- version: v12.12.0
|
||||
pr-url: https://github.com/nodejs/node/pull/29876
|
||||
description: The `fd` option may now be a `FileHandle`.
|
||||
@@ -1551,6 +1558,9 @@ server.on('stream', (stream) => {
|
||||
<!-- YAML
|
||||
added: v8.4.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/33160
|
||||
description: Allow explicity setting date headers.
|
||||
- version: v10.0.0
|
||||
pr-url: https://github.com/nodejs/node/pull/18936
|
||||
description: Any readable file, not necessarily a
|
||||
|
||||
@@ -2222,7 +2222,10 @@ function processHeaders(oldHeaders) {
|
||||
const statusCode =
|
||||
headers[HTTP2_HEADER_STATUS] =
|
||||
headers[HTTP2_HEADER_STATUS] | 0 || HTTP_STATUS_OK;
|
||||
headers[HTTP2_HEADER_DATE] = utcDate();
|
||||
|
||||
if (headers[HTTP2_HEADER_DATE] === null ||
|
||||
headers[HTTP2_HEADER_DATE] === undefined)
|
||||
headers[HTTP2_HEADER_DATE] = utcDate();
|
||||
|
||||
// This is intentionally stricter than the HTTP/1 implementation, which
|
||||
// allows values between 100 and 999 (inclusive) in order to allow for
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto) { common.skip('missing crypto'); }
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
const server = http2.createServer(common.mustCall((request, response) => {
|
||||
response.setHeader('date', 'snacks o clock');
|
||||
response.end();
|
||||
}));
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const session = http2.connect(`http://localhost:${server.address().port}`);
|
||||
const req = session.request();
|
||||
req.on('response', (headers, flags) => {
|
||||
assert.deepStrictEqual(headers.date, 'snacks o clock');
|
||||
});
|
||||
req.on('end', () => {
|
||||
session.close();
|
||||
server.close();
|
||||
});
|
||||
}));
|
||||
Reference in new issue
Block a user