-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
- Loading branch information
1 parent
db6490c
commit e2b81e1
Showing
5 changed files
with
52 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(); | ||
})); |