mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
http: move utcDate to internal/http.js
Backport-PR-URL: https://github.com/nodejs/node/pull/14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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:
1 parent
9e51802f53
commit
e0001dc601
2 files changed
+19
-17
No files matched your search
Regular → Executable
+2
-17
@@ -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;
|
||||
@@ -36,6 +36,7 @@ const nextTick = require('internal/process/next_tick').nextTick;
|
||||
|
||||
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;
|
||||
@@ -63,24 +64,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);
|
||||
|
||||
|
||||
Regular → Executable
+17
@@ -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
|
||||
};
|
||||
Reference in new issue
Block a user