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.
stream: remove kludge masking RST on Windows
Remove the kludge that masks the TCP RST on Windows on test-https-truncate That RST is very real, originates from the server and should be investigated Fixes: nodejs#35904
- Loading branch information
Showing
3 changed files
with
58 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const tls = require('tls'); | ||
const fixtures = require('../common/fixtures'); | ||
const https = require('https'); | ||
const key = fixtures.readKey('agent1-key.pem'); | ||
const cert = fixtures.readKey('agent1-cert.pem'); | ||
const net = require('net'); | ||
const { Duplex } = require('stream'); | ||
|
||
class CustomAgent extends https.Agent { | ||
createConnection(options, cb) { | ||
const realSocket = net.createConnection(options); | ||
const stream = new Duplex({ | ||
emitClose: false, | ||
read(n) { | ||
(function retry() { | ||
const data = realSocket.read(); | ||
if (data === null) | ||
return realSocket.once('readable', retry); | ||
stream.push(data); | ||
})(); | ||
}, | ||
write(chunk, enc, callback) { | ||
realSocket.write(chunk, enc, callback); | ||
}, | ||
}); | ||
realSocket.on('end', () => stream.push(null)); | ||
|
||
stream.on('end', common.mustCall()); | ||
return tls.connect({ ...options, socket: stream }); | ||
} | ||
} | ||
|
||
const httpsServer = https.createServer({ | ||
key, | ||
cert, | ||
}, (req, res) => { | ||
httpsServer.close(); | ||
res.end('hello world!'); | ||
}); | ||
httpsServer.listen(0, 'localhost', () => { | ||
const agent = new CustomAgent(); | ||
https.get({ | ||
host: 'localhost', | ||
port: httpsServer.address().port, | ||
agent, | ||
headers: { Connection: 'close' }, | ||
rejectUnauthorized: false | ||
}, (res) => { | ||
res.resume(); | ||
}); | ||
}); |
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