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:
parent
1abfbbb1c4
commit
9ea363ee99
19
lib/_http_outgoing.js
Normal file → Executable file
19
lib/_http_outgoing.js
Normal file → Executable file
@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
const assert = require('assert').ok;
|
const assert = require('assert').ok;
|
||||||
const Stream = require('stream');
|
const Stream = require('stream');
|
||||||
const timers = require('timers');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const internalUtil = require('internal/util');
|
const internalUtil = require('internal/util');
|
||||||
|
const internalHttp = require('internal/http');
|
||||||
const Buffer = require('buffer').Buffer;
|
const Buffer = require('buffer').Buffer;
|
||||||
const common = require('_http_common');
|
const common = require('_http_common');
|
||||||
const checkIsHttpToken = common._checkIsHttpToken;
|
const checkIsHttpToken = common._checkIsHttpToken;
|
||||||
@ -37,6 +37,7 @@ const errors = require('internal/errors');
|
|||||||
|
|
||||||
const CRLF = common.CRLF;
|
const CRLF = common.CRLF;
|
||||||
const debug = common.debug;
|
const debug = common.debug;
|
||||||
|
const utcDate = internalHttp.utcDate;
|
||||||
|
|
||||||
var RE_FIELDS =
|
var RE_FIELDS =
|
||||||
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
|
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
|
||||||
@ -64,24 +65,8 @@ function isCookieField(s) {
|
|||||||
return true;
|
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 noopPendingOutput(amount) {}
|
||||||
|
|
||||||
|
|
||||||
function OutgoingMessage() {
|
function OutgoingMessage() {
|
||||||
Stream.call(this);
|
Stream.call(this);
|
||||||
|
|
||||||
|
17
lib/internal/http.js
Normal file → Executable file
17
lib/internal/http.js
Normal file → Executable file
@ -1,5 +1,21 @@
|
|||||||
'use strict';
|
'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() {
|
function ondrain() {
|
||||||
if (this._httpMessage) this._httpMessage.emit('drain');
|
if (this._httpMessage) this._httpMessage.emit('drain');
|
||||||
}
|
}
|
||||||
@ -7,4 +23,5 @@ function ondrain() {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
outHeadersKey: Symbol('outHeadersKey'),
|
outHeadersKey: Symbol('outHeadersKey'),
|
||||||
ondrain,
|
ondrain,
|
||||||
|
utcDate
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user