forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-https-end-rst.js
More file actions
40 lines (35 loc) · 1020 Bytes
/
test-https-end-rst.js
File metadata and controls
40 lines (35 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const https = require('https');
const tls = require('tls');
const fixtures = require('../common/fixtures');
const opt = {
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
};
const data = 'hello';
const server = https.createServer(opt, common.mustCallAtLeast((req, res) => {
res.setHeader('content-length', data.length);
res.end(data);
}, 2));
server.listen(0, function() {
const options = {
host: '127.0.0.1',
port: server.address().port,
rejectUnauthorized: false,
ALPNProtocols: ['http/1.1'],
allowHalfOpen: true
};
const socket = tls.connect(options, common.mustCall(() => {
socket.write('GET /\n\n');
socket.once('data', common.mustCall(() => {
socket.write('GET /\n\n');
setTimeout(common.mustCall(() => {
socket.destroy();
server.close();
}), common.platformTimeout(10));
}));
}));
});