http: move utcDate to internal/http.js
PR-URL: https://github.com/nodejs/node/pull/14239 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Родитель
1abfbbb1c4
Коммит
9ea363ee99
|
@ -23,9 +23,9 @@
|
|||
|
||||
const assert = require('assert').ok;
|
||||
const Stream = require('stream');
|
||||
const timers = require('timers');
|
||||
const util = require('util');
|
||||
const internalUtil = require('internal/util');
|
||||
const internalHttp = require('internal/http');
|
||||
const Buffer = require('buffer').Buffer;
|
||||
const common = require('_http_common');
|
||||
const checkIsHttpToken = common._checkIsHttpToken;
|
||||
|
@ -37,6 +37,7 @@ const errors = require('internal/errors');
|
|||
|
||||
const CRLF = common.CRLF;
|
||||
const debug = common.debug;
|
||||
const utcDate = internalHttp.utcDate;
|
||||
|
||||
var RE_FIELDS =
|
||||
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
|
||||
|
@ -64,24 +65,8 @@ function isCookieField(s) {
|
|||
return true;
|
||||
}
|
||||
|
||||
var dateCache;
|
||||
function utcDate() {
|
||||
if (!dateCache) {
|
||||
var d = new Date();
|
||||
dateCache = d.toUTCString();
|
||||
timers.enroll(utcDate, 1000 - d.getMilliseconds());
|
||||
timers._unrefActive(utcDate);
|
||||
}
|
||||
return dateCache;
|
||||
}
|
||||
utcDate._onTimeout = function _onTimeout() {
|
||||
dateCache = undefined;
|
||||
};
|
||||
|
||||
|
||||
function noopPendingOutput(amount) {}
|
||||
|
||||
|
||||
function OutgoingMessage() {
|
||||
Stream.call(this);
|
||||
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
'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');
|
||||
}
|
||||
|
@ -7,4 +23,5 @@ function ondrain() {
|
|||
module.exports = {
|
||||
outHeadersKey: Symbol('outHeadersKey'),
|
||||
ondrain,
|
||||
utcDate
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче