forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net,tls,test: remove writeQueueSize and fix bufferSize
When use TLSSocket, bufferSize is always +1, this affects users who rely on this property to make judgments. This commit removed legacy code and corrected the calculation of bufferSize. Fixes: nodejs#15005
- Loading branch information
Showing
3 changed files
with
38 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const tls = require('tls'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
const options = { | ||
key: fixtures.readSync('test_key.pem'), | ||
cert: fixtures.readSync('test_cert.pem') | ||
}; | ||
|
||
const iter = 10; | ||
|
||
const server = tls.createServer(options, (socket) => { | ||
socket.pipe(socket); | ||
socket.on('end', () => { | ||
server.close(); | ||
}); | ||
}); | ||
|
||
server.listen(0, () => { | ||
const client = tls.connect({ | ||
port: server.address().port, | ||
rejectUnauthorized: false | ||
}, () => { | ||
for (let i = 1; i < iter; i++) { | ||
client.write('a'); | ||
assert.strictEqual(client.bufferSize, i); | ||
} | ||
client.end(); | ||
}); | ||
|
||
client.on('finish', () => { | ||
assert.strictEqual(client.bufferSize, 0); | ||
}); | ||
}); |