-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: make socketPath work with no agent
Currently `Agent.prototype.createConnection()` is called uncoditionally if the `socketPath` option is used. This throws an error if no agent is used, preventing, for example, the `socketPath` and `createConnection` options to be used together. This commit fixes the issue by falling back to the `createConnection` option or `net.createConnection()`. PR-URL: #19425 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Chen Gang <[email protected]>
- Loading branch information
1 parent
1edadeb
commit 18acad3
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const Countdown = require('../common/countdown'); | ||
|
||
const http = require('http'); | ||
const { createConnection } = require('net'); | ||
|
||
const server = http.createServer((req, res) => { | ||
res.end(); | ||
}); | ||
|
||
const countdown = new Countdown(2, () => { | ||
server.close(); | ||
}); | ||
|
||
common.refreshTmpDir(); | ||
|
||
server.listen(common.PIPE, common.mustCall(() => { | ||
http.get({ createConnection, socketPath: common.PIPE }, onResponse); | ||
http.get({ agent: 0, socketPath: common.PIPE }, onResponse); | ||
})); | ||
|
||
function onResponse(res) { | ||
res.on('end', () => { | ||
countdown.dec(); | ||
}); | ||
res.resume(); | ||
} |