Skip to content
Closed
Changes from all commits
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
11 changes: 6 additions & 5 deletions lib/internal/http.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'use strict';

const timers = require('timers');
const { setUnrefTimeout } = require('internal/timers');

var dateCache;
function utcDate() {
if (!dateCache) {
const d = new Date();
dateCache = d.toUTCString();
timers.enroll(utcDate, 1000 - d.getMilliseconds());
timers._unrefActive(utcDate);

setUnrefTimeout(timeout, 1000 - d.getMilliseconds());
}
return dateCache;
}
utcDate._onTimeout = function() {

function timeout() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this function resetCache or sth like that, timeout doesn't really say what it's doing...

dateCache = undefined;
};
}

function ondrain() {
if (this._httpMessage) this._httpMessage.emit('drain');
Expand Down