| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -336,7 +336,16 @@ function ClientRequest(input, options, cb) { | |||
| 336 | 336 | // No agent, default to Connection:close. | |
| 337 | 337 | this._last = true; | |
| 338 | 338 | this.shouldKeepAlive = false; | |
| 339 | - if (typeof optsWithoutSignal.createConnection === 'function') { | ||
| 339 | + let opts = optsWithoutSignal; | ||
| 340 | + if (opts.path || opts.socketPath) { | ||
| 341 | + opts = { ...optsWithoutSignal }; | ||
| 342 | + if (opts.socketPath) { | ||
| 343 | + opts.path = opts.socketPath; | ||
| 344 | + } else if (opts.path) { | ||
| 345 | + opts.path = undefined; | ||
| 346 | + } | ||
| 347 | + } | ||
| 348 | + if (typeof opts.createConnection === 'function') { | ||
| 340 | 349 | const oncreate = once((err, socket) => { | |
| 341 | 350 | if (err) { | |
| 342 | 351 | process.nextTick(() => this.emit('error', err)); | |
@@ -346,17 +355,16 @@ function ClientRequest(input, options, cb) { | |||
| 346 | 355 | }); | |
| 347 | 356 | ||
| 348 | 357 | try { | |
| 349 | - const newSocket = optsWithoutSignal.createConnection(optsWithoutSignal, | ||
| 350 | - oncreate); | ||
| 358 | + const newSocket = opts.createConnection(opts, oncreate); | ||
| 351 | 359 | if (newSocket) { | |
| 352 | 360 | oncreate(null, newSocket); | |
| 353 | 361 | } | |
| 354 | 362 | } catch (err) { | |
| 355 | 363 | oncreate(err); | |
| 356 | 364 | } | |
| 357 | 365 | } else { | |
| 358 | - debug('CLIENT use net.createConnection', optsWithoutSignal); | ||
| 359 | - this.onSocket(net.createConnection(optsWithoutSignal)); | ||
| 366 | + debug('CLIENT use net.createConnection', opts); | ||
| 367 | + this.onSocket(net.createConnection(opts)); | ||
| 360 | 368 | } | |
| 361 | 369 | } | |
| 362 | 370 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,55 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const http = require('http'); | ||
| 4 | + const net = require('net'); | ||
| 5 | + const tmpdir = require('../common/tmpdir'); | ||
| 6 | + | ||
| 7 | + tmpdir.refresh(); | ||
| 8 | + | ||
| 9 | + let count = 0; | ||
| 10 | + let server1; | ||
| 11 | + let server2; | ||
| 12 | + | ||
| 13 | + function request(options) { | ||
| 14 | + count++; | ||
| 15 | + http.get({ | ||
| 16 | + ...options, | ||
| 17 | + createConnection: (...args) => { | ||
| 18 | + return net.connect(...args); | ||
| 19 | + } | ||
| 20 | + }, (res) => { | ||
| 21 | + res.resume(); | ||
| 22 | + res.on('end', () => { | ||
| 23 | + if (--count === 0) { | ||
| 24 | + server1.close(); | ||
| 25 | + server2.close(); | ||
| 26 | + } | ||
| 27 | + }); | ||
| 28 | + }); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + server1 = http.createServer((req, res) => { | ||
| 32 | + res.end('ok'); | ||
| 33 | + }).listen(common.PIPE, () => { | ||
| 34 | + server2 = http.createServer((req, res) => { | ||
| 35 | + res.end('ok'); | ||
| 36 | + }).listen(() => { | ||
| 37 | + request({ | ||
| 38 | + path: '/', | ||
| 39 | + socketPath: common.PIPE, | ||
| 40 | + }); | ||
| 41 | + | ||
| 42 | + request({ | ||
| 43 | + socketPath: common.PIPE, | ||
| 44 | + }); | ||
| 45 | + | ||
| 46 | + request({ | ||
| 47 | + path: '/', | ||
| 48 | + port: server2.address().port, | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + request({ | ||
| 52 | + port: server2.address().port, | ||
| 53 | + }); | ||
| 54 | + }); | ||
| 55 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments