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