Skip to content

Commit 865bdb3

Browse files
committed
fixup
1 parent eba16c1 commit 865bdb3

2 files changed

Lines changed: 3 additions & 53 deletions

File tree

doc/api/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ changes:
18051805

18061806
* `statusCode` {number}
18071807
* `statusMessage` {string}
1808-
* `headers` {Object}
1808+
* `headers` {Object|Array}
18091809
* Returns: {http.ServerResponse}
18101810

18111811
Sends a response header to the request. The status code is a 3-digit HTTP

test/parallel/test-https-server-request-timeout.js

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,19 @@ if (!common.hasCrypto)
55
common.skip('missing crypto');
66
const assert = require('assert');
77
const { createServer } = require('https');
8-
const { connect } = require('tls');
98
const fixtures = require('../common/fixtures');
109

1110
const options = {
1211
key: fixtures.readKey('agent1-key.pem'),
1312
cert: fixtures.readKey('agent1-cert.pem')
1413
};
1514

16-
// This test validates that the server returns 408
17-
// after server.requestTimeout if the client
18-
// pauses before start sending the body.
19-
20-
const server = createServer(options, common.mustCall((req, res) => {
21-
let body = '';
22-
req.setEncoding('utf-8');
23-
24-
req.on('data', (chunk) => {
25-
body += chunk;
26-
});
27-
28-
req.on('end', () => {
29-
res.writeHead(200, { 'Content-Type': 'text/plain' });
30-
res.write(body);
31-
res.end();
32-
});
33-
}));
15+
const server = createServer(options);
3416

3517
// 0 seconds is the default
3618
assert.strictEqual(server.requestTimeout, 0);
3719
const requestTimeout = common.platformTimeout(1000);
3820
server.requestTimeout = requestTimeout;
3921
assert.strictEqual(server.requestTimeout, requestTimeout);
4022

41-
server.listen(0, common.mustCall(() => {
42-
const client = connect({
43-
host: '127.0.0.1',
44-
port: server.address().port,
45-
rejectUnauthorized: false
46-
});
47-
let response = '';
48-
49-
client.on('data', common.mustCall((chunk) => {
50-
response += chunk.toString('utf-8');
51-
}));
52-
53-
client.resume();
54-
client.write('POST / HTTP/1.1\r\n');
55-
client.write('Content-Length: 20\r\n');
56-
client.write('Connection: close\r\n');
57-
client.write('\r\n');
58-
59-
setTimeout(() => {
60-
client.write('12345678901234567890\r\n\r\n');
61-
}, common.platformTimeout(2000)).unref();
62-
63-
const errOrEnd = common.mustCall(function(err) {
64-
assert.strictEqual(
65-
response,
66-
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
67-
);
68-
server.close();
69-
});
70-
71-
client.on('end', errOrEnd);
72-
client.on('error', errOrEnd);
73-
}));
23+
server.close();

0 commit comments

Comments
 (0)