-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: make TCP noDelay enabled by default
PR-URL: #42163 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
- Loading branch information
1 parent
6b004f1
commit eacd456
Showing
5 changed files
with
55 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
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
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,37 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
|
||
const originalConnect = net.Socket.prototype.connect; | ||
|
||
net.Socket.prototype.connect = common.mustCall(function(args) { | ||
assert.strictEqual(args[0].noDelay, true); | ||
return originalConnect.call(this, args); | ||
}); | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.writeHead(200); | ||
res.end(); | ||
server.close(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
assert.strictEqual(server.noDelay, true); | ||
|
||
const req = http.request({ | ||
method: 'GET', | ||
port: server.address().port | ||
}, common.mustCall((res) => { | ||
res.on('end', () => { | ||
server.close(); | ||
res.req.socket.end(); | ||
}); | ||
|
||
res.resume(); | ||
})); | ||
|
||
req.end(); | ||
})); |