diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js old mode 100644 new mode 100755 index 31973fceadb6b8..03a121ce7edfaa --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -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); diff --git a/lib/internal/http.js b/lib/internal/http.js old mode 100644 new mode 100755 index 0b12bc7c8fbe85..71e32498f359a1 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -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 };