This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: do not blindly destroy UNIX domain sockets
`Connection: keep-alive` is now properly supported when making client connections to UNIX domain sockets so `request.abort()` should not blindly destroy the underlying socket. PR-URL: nodejs/node#15650 Refs: nodejs/node#13214 (comment) Reviewed-By: Anatoli Papirovski <[email protected]>
- Loading branch information
Showing
3 changed files
with
39 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
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
test/parallel/test-http-client-abort-keep-alive-queued-unix-socket.js
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,38 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
let socketsCreated = 0; | ||
|
||
class Agent extends http.Agent { | ||
createConnection(options, oncreate) { | ||
const socket = super.createConnection(options, oncreate); | ||
socketsCreated++; | ||
return socket; | ||
} | ||
} | ||
|
||
const server = http.createServer((req, res) => res.end()); | ||
|
||
const socketPath = common.PIPE; | ||
common.refreshTmpDir(); | ||
|
||
server.listen(socketPath, common.mustCall(() => { | ||
const agent = new Agent({ | ||
keepAlive: true, | ||
maxSockets: 1 | ||
}); | ||
|
||
http.get({ agent, socketPath }, (res) => res.resume()); | ||
|
||
const req = http.get({ agent, socketPath }, common.mustNotCall()); | ||
req.abort(); | ||
|
||
http.get({ agent, socketPath }, common.mustCall((res) => { | ||
res.resume(); | ||
assert.strictEqual(socketsCreated, 1); | ||
agent.destroy(); | ||
server.close(); | ||
})); | ||
})); |