(exports)
| 177 | // |
| 178 | var require_tunnel = __commonJS({ |
| 179 | ""(exports) { |
| 180 | "use strict"; |
| 181 | var net = __require("net"); |
| 182 | var tls = __require("tls"); |
| 183 | var http = __require("http"); |
| 184 | var https = __require("https"); |
| 185 | var events2 = __require("events"); |
| 186 | var assert = __require("assert"); |
| 187 | var util = __require("util"); |
| 188 | exports.httpOverHttp = httpOverHttp2; |
| 189 | exports.httpsOverHttp = httpsOverHttp2; |
| 190 | exports.httpOverHttps = httpOverHttps2; |
| 191 | exports.httpsOverHttps = httpsOverHttps2; |
| 192 | function httpOverHttp2(options) { |
| 193 | var agent = new TunnelingAgent(options); |
| 194 | agent.request = http.request; |
| 195 | return agent; |
| 196 | } |
| 197 | function httpsOverHttp2(options) { |
| 198 | var agent = new TunnelingAgent(options); |
| 199 | agent.request = http.request; |
| 200 | agent.createSocket = createSecureSocket; |
| 201 | agent.defaultPort = 443; |
| 202 | return agent; |
| 203 | } |
| 204 | function httpOverHttps2(options) { |
| 205 | var agent = new TunnelingAgent(options); |
| 206 | agent.request = https.request; |
| 207 | return agent; |
| 208 | } |
| 209 | function httpsOverHttps2(options) { |
| 210 | var agent = new TunnelingAgent(options); |
| 211 | agent.request = https.request; |
| 212 | agent.createSocket = createSecureSocket; |
| 213 | agent.defaultPort = 443; |
| 214 | return agent; |
| 215 | } |
| 216 | function TunnelingAgent(options) { |
| 217 | var self = this; |
| 218 | self.options = options || {}; |
| 219 | self.proxyOptions = self.options.proxy || {}; |
| 220 | self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; |
| 221 | self.requests = []; |
| 222 | self.sockets = []; |
| 223 | self.on("free", function onFree(socket, host, port, localAddress) { |
| 224 | var options2 = toOptions(host, port, localAddress); |
| 225 | for (var i = 0, len = self.requests.length; i < len; ++i) { |
| 226 | var pending = self.requests[i]; |
| 227 | if (pending.host === options2.host && pending.port === options2.port) { |
| 228 | self.requests.splice(i, 1); |
| 229 | pending.request.onSocket(socket); |
| 230 | return; |
| 231 | } |
| 232 | } |
| 233 | socket.destroy(); |
| 234 | self.removeSocket(socket); |
| 235 | }); |
| 236 | } |
nothing calls this directly
no test coverage detected