Skip to content

Commit 7e3ad1b

Browse files
Lxxyxdanielleadams
authored andcommitted
Revert "http: remove dead code from internal/http.js"
This reverts commit 9156f43. PR-URL: #36890 Refs: #32329 Reviewed-By: Danielle Adams <[email protected]>
1 parent abc2ff4 commit 7e3ad1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/internal/http.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,28 @@ const {
1111
const { setUnrefTimeout } = require('internal/timers');
1212
const { PerformanceEntry, notify } = internalBinding('performance');
1313

14+
let nowCache;
1415
let utcCache;
1516

17+
function nowDate() {
18+
if (!nowCache) cache();
19+
return nowCache;
20+
}
21+
1622
function utcDate() {
1723
if (!utcCache) cache();
1824
return utcCache;
1925
}
2026

2127
function cache() {
2228
const d = new Date();
23-
utcCache = d.toUTCString();
24-
setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
29+
nowCache = DatePrototypeValueOf(d);
30+
utcCache = DatePrototypeToUTCString(d);
31+
setUnrefTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds(d));
2532
}
2633

2734
function resetCache() {
35+
nowCache = undefined;
2836
utcCache = undefined;
2937
}
3038

@@ -47,6 +55,7 @@ function emitStatistics(statistics) {
4755
module.exports = {
4856
kOutHeaders: Symbol('kOutHeaders'),
4957
kNeedDrain: Symbol('kNeedDrain'),
58+
nowDate,
5059
utcDate,
5160
emitStatistics
5261
};

0 commit comments

Comments
 (0)