Skip to content

Commit

Permalink
Revert "http: remove dead code from internal/http.js"
Browse files Browse the repository at this point in the history
This reverts commit 9156f43.

PR-URL: #36890
Refs: #32329
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
  • Loading branch information
Lxxyx authored and danielleadams committed Jan 13, 2021
1 parent abc2ff4 commit 7e3ad1b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/internal/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@ const {
const { setUnrefTimeout } = require('internal/timers');
const { PerformanceEntry, notify } = internalBinding('performance');

let nowCache;
let utcCache;

function nowDate() {
if (!nowCache) cache();
return nowCache;
}

function utcDate() {
if (!utcCache) cache();
return utcCache;
}

function cache() {
const d = new Date();
utcCache = d.toUTCString();
setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
nowCache = DatePrototypeValueOf(d);
utcCache = DatePrototypeToUTCString(d);
setUnrefTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds(d));
}

function resetCache() {
nowCache = undefined;
utcCache = undefined;
}

Expand All @@ -47,6 +55,7 @@ function emitStatistics(statistics) {
module.exports = {
kOutHeaders: Symbol('kOutHeaders'),
kNeedDrain: Symbol('kNeedDrain'),
nowDate,
utcDate,
emitStatistics
};

0 comments on commit 7e3ad1b

Please sign in to comment.