| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7f86e81 commit 08b75c1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,13 +25,8 @@ require('internal/util').assertCrypto(); | |||
| 25 | 25 | ||
| 26 | 26 | const tls = require('tls'); | |
| 27 | 27 | const url = require('url'); | |
| 28 | + const http = require('http'); | ||
| 28 | 29 | const util = require('util'); | |
| 29 | - const { Agent: HttpAgent } = require('_http_agent'); | ||
| 30 | - const { | ||
| 31 | - Server: HttpServer, | ||
| 32 | - _connectionListener | ||
| 33 | - } = require('_http_server'); | ||
| 34 | - const { ClientRequest } = require('_http_client'); | ||
| 35 | 30 | const { inherits } = util; | |
| 36 | 31 | const debug = util.debuglog('https'); | |
| 37 | 32 | const { urlToOptions, searchParamsSymbol } = require('internal/url'); | |
@@ -56,7 +51,7 @@ function Server(opts, requestListener) { | |||
| 56 | 51 | opts.ALPNProtocols = ['http/1.1']; | |
| 57 | 52 | } | |
| 58 | 53 | ||
| 59 | - tls.Server.call(this, opts, _connectionListener); | ||
| 54 | + tls.Server.call(this, opts, http._connectionListener); | ||
| 60 | 55 | ||
| 61 | 56 | this.httpAllowHalfOpen = false; | |
| 62 | 57 | ||
@@ -73,12 +68,13 @@ function Server(opts, requestListener) { | |||
| 73 | 68 | this.keepAliveTimeout = 5000; | |
| 74 | 69 | } | |
| 75 | 70 | inherits(Server, tls.Server); | |
| 71 | + exports.Server = Server; | ||
| 76 | 72 | ||
| 77 | - Server.prototype.setTimeout = HttpServer.prototype.setTimeout; | ||
| 73 | + Server.prototype.setTimeout = http.Server.prototype.setTimeout; | ||
| 78 | 74 | ||
| 79 | - function createServer(opts, requestListener) { | ||
| 75 | + exports.createServer = function createServer(opts, requestListener) { | ||
| 80 | 76 | return new Server(opts, requestListener); | |
| 81 | - } | ||
| 77 | + }; | ||
| 82 | 78 | ||
| 83 | 79 | ||
| 84 | 80 | // HTTPS agents. | |
@@ -133,7 +129,7 @@ function Agent(options) { | |||
| 133 | 129 | if (!(this instanceof Agent)) | |
| 134 | 130 | return new Agent(options); | |
| 135 | 131 | ||
| 136 | - HttpAgent.call(this, options); | ||
| 132 | + http.Agent.call(this, options); | ||
| 137 | 133 | this.defaultPort = 443; | |
| 138 | 134 | this.protocol = 'https:'; | |
| 139 | 135 | this.maxCachedSessions = this.options.maxCachedSessions; | |
@@ -145,11 +141,11 @@ function Agent(options) { | |||
| 145 | 141 | list: [] | |
| 146 | 142 | }; | |
| 147 | 143 | } | |
| 148 | - inherits(Agent, HttpAgent); | ||
| 144 | + inherits(Agent, http.Agent); | ||
| 149 | 145 | Agent.prototype.createConnection = createConnection; | |
| 150 | 146 | ||
| 151 | 147 | Agent.prototype.getName = function getName(options) { | |
| 152 | - var name = HttpAgent.prototype.getName.call(this, options); | ||
| 148 | + var name = http.Agent.prototype.getName.call(this, options); | ||
| 153 | 149 | ||
| 154 | 150 | name += ':'; | |
| 155 | 151 | if (options.ca) | |
@@ -223,7 +219,10 @@ Agent.prototype._evictSession = function _evictSession(key) { | |||
| 223 | 219 | ||
| 224 | 220 | const globalAgent = new Agent(); | |
| 225 | 221 | ||
| 226 | - function request(options, cb) { | ||
| 222 | + exports.globalAgent = globalAgent; | ||
| 223 | + exports.Agent = Agent; | ||
| 224 | + | ||
| 225 | + exports.request = function request(options, cb) { | ||
| 227 | 226 | if (typeof options === 'string') { | |
| 228 | 227 | options = url.parse(options); | |
| 229 | 228 | if (!options.hostname) { | |
@@ -237,20 +236,11 @@ function request(options, cb) { | |||
| 237 | 236 | options = util._extend({}, options); | |
| 238 | 237 | } | |
| 239 | 238 | options._defaultAgent = globalAgent; | |
| 240 | - return new ClientRequest(options, cb); | ||
| 241 | - } | ||
| 239 | + return http.request(options, cb); | ||
| 240 | + }; | ||
| 242 | 241 | ||
| 243 | - function get(options, cb) { | ||
| 244 | - const req = request(options, cb); | ||
| 242 | + exports.get = function get(options, cb) { | ||
| 243 | + var req = exports.request(options, cb); | ||
| 245 | 244 | req.end(); | |
| 246 | 245 | return req; | |
| 247 | - } | ||
| 248 | - | ||
| 249 | - module.exports = { | ||
| 250 | - Agent, | ||
| 251 | - globalAgent, | ||
| 252 | - Server, | ||
| 253 | - createServer, | ||
| 254 | - get, | ||
| 255 | - request | ||
| 256 | 246 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments