diff options
author | James M Snell <jasnell@gmail.com> | 2017-02-27 16:09:32 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-03-20 16:01:31 -0700 |
commit | 5425e0dcbee1ed8f6687203eafb7c3cf214f3393 (patch) | |
tree | aa22fd8a72932ace744132fcebc460d003f082be /lib/http.js | |
parent | 2a4a5f0389679481b4aaafddf9fa780022b41cbb (diff) | |
download | node-new-5425e0dcbee1ed8f6687203eafb7c3cf214f3393.tar.gz |
http: use more efficient module.exports pattern
PR-URL: https://github.com/nodejs/node/pull/11594
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/http.js')
-rw-r--r-- | lib/http.js | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/lib/http.js b/lib/http.js index 4b0e589a56..af3e8a017c 100644 --- a/lib/http.js +++ b/lib/http.js @@ -20,35 +20,43 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -exports.IncomingMessage = require('_http_incoming').IncomingMessage; - -exports.OutgoingMessage = require('_http_outgoing').OutgoingMessage; - -exports.METHODS = require('_http_common').methods.slice().sort(); const agent = require('_http_agent'); -exports.Agent = agent.Agent; -exports.globalAgent = agent.globalAgent; - +const client = require('_http_client'); +const common = require('_http_common'); +const incoming = require('_http_incoming'); +const outgoing = require('_http_outgoing'); const server = require('_http_server'); -exports.ServerResponse = server.ServerResponse; -exports.STATUS_CODES = server.STATUS_CODES; -exports._connectionListener = server._connectionListener; -const Server = exports.Server = server.Server; -exports.createServer = function createServer(requestListener) { - return new Server(requestListener); -}; +const Server = server.Server; +const ClientRequest = client.ClientRequest; -const client = require('_http_client'); -const ClientRequest = exports.ClientRequest = client.ClientRequest; +function createServer(requestListener) { + return new Server(requestListener); +} -exports.request = function request(options, cb) { +function request(options, cb) { return new ClientRequest(options, cb); -}; +} -exports.get = function get(options, cb) { - var req = exports.request(options, cb); +function get(options, cb) { + var req = request(options, cb); req.end(); return req; +} + +module.exports = { + _connectionListener: server._connectionListener, + METHODS: common.methods.slice().sort(), + STATUS_CODES: server.STATUS_CODES, + Agent: agent.Agent, + ClientRequest, + globalAgent: agent.globalAgent, + IncomingMessage: incoming.IncomingMessage, + OutgoingMessage: outgoing.OutgoingMessage, + Server, + ServerResponse: server.ServerResponse, + createServer, + get, + request }; |