0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/lib/internal/http.js

29 lines
495 B
JavaScript
Raw Normal View History

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