node/lib/internal/http.js

28 lines
511 B
JavaScript
Raw Normal View History

'use strict';
const timers = require('timers');
var dateCache;
function utcDate() {
if (!dateCache) {
const d = new Date();
dateCache = d.toUTCString();
timers.enroll(utcDate, 1000 - d.getMilliseconds());
timers._unrefActive(utcDate);
}
return dateCache;
}
utcDate._onTimeout = function() {
dateCache = undefined;
};
function ondrain() {
if (this._httpMessage) this._httpMessage.emit('drain');
}
module.exports = {
outHeadersKey: Symbol('outHeadersKey'),
ondrain,
utcDate
};