2017-03-06 02:13:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-12-21 02:50:19 +00:00
|
|
|
const { setUnrefTimeout } = require('internal/timers');
|
2016-10-17 18:38:52 +00:00
|
|
|
|
2018-08-23 14:46:07 +00:00
|
|
|
var nowCache;
|
|
|
|
var utcCache;
|
|
|
|
|
|
|
|
function nowDate() {
|
|
|
|
if (!nowCache) cache();
|
|
|
|
return nowCache;
|
|
|
|
}
|
|
|
|
|
2016-10-17 18:38:52 +00:00
|
|
|
function utcDate() {
|
2018-08-23 14:46:07 +00:00
|
|
|
if (!utcCache) cache();
|
|
|
|
return utcCache;
|
|
|
|
}
|
2017-12-21 02:50:19 +00:00
|
|
|
|
2018-08-23 14:46:07 +00:00
|
|
|
function cache() {
|
|
|
|
const d = new Date();
|
|
|
|
nowCache = d.valueOf();
|
|
|
|
utcCache = d.toUTCString();
|
|
|
|
setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
|
2016-10-17 18:38:52 +00:00
|
|
|
}
|
2017-12-21 02:50:19 +00:00
|
|
|
|
|
|
|
function resetCache() {
|
2018-08-23 14:46:07 +00:00
|
|
|
nowCache = undefined;
|
|
|
|
utcCache = undefined;
|
2017-12-21 02:50:19 +00:00
|
|
|
}
|
2016-10-17 18:38:52 +00:00
|
|
|
|
2017-03-19 19:58:31 +00:00
|
|
|
function ondrain() {
|
|
|
|
if (this._httpMessage) this._httpMessage.emit('drain');
|
|
|
|
}
|
|
|
|
|
2017-03-06 02:13:09 +00:00
|
|
|
module.exports = {
|
2017-03-19 19:58:31 +00:00
|
|
|
outHeadersKey: Symbol('outHeadersKey'),
|
|
|
|
ondrain,
|
2018-08-23 14:46:07 +00:00
|
|
|
nowDate,
|
2016-10-17 18:38:52 +00:00
|
|
|
utcDate
|
2017-03-06 02:13:09 +00:00
|
|
|
};
|