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