Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
http2: simplify options.sendDate assertion in headers
  • Loading branch information
joaolucasl committed Aug 22, 2020
commit 3cb8d7221a571a0d43e7f18ebda92422427e73e0
13 changes: 6 additions & 7 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2292,13 +2292,12 @@ function processHeaders(oldHeaders, options) {
headers[HTTP2_HEADER_STATUS] =
headers[HTTP2_HEADER_STATUS] | 0 || HTTP_STATUS_OK;

let sendDate = true;
if (options.sendDate !== null && options.sendDate !== undefined)
sendDate = options.sendDate;

if (sendDate && (headers[HTTP2_HEADER_DATE] === null ||
headers[HTTP2_HEADER_DATE] === undefined))
headers[HTTP2_HEADER_DATE] = utcDate();
if (options.sendDate == null || options.sendDate) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ server.listen(0, common.mustCall(() => {
const session = http2.connect(`http://localhost:${server.address().port}`);
const req = session.request();

req.on('response', (headers, flags) => {
req.on('response', common.mustCall((headers, flags) => {
assert.strictEqual('Date' in headers, false);
assert.strictEqual('date' in headers, false);
});
}));

req.on('end', () => {
req.on('end', common.mustCall(() => {
session.close();
server.close();
});
}));
}));