We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c2c100 commit c9dc0a8Copy full SHA for c9dc0a8
2 files changed
lib/_http_server.js
@@ -918,8 +918,6 @@ function socketOnError(e) {
918
}
919
920
function onParserExecuteCommon(server, socket, parser, state, ret, d) {
921
- resetSocketTimeout(server, socket, state);
922
-
923
if (ret instanceof Error) {
924
prepareError(ret, parser, d);
925
debug('parse error', ret);
test/parallel/test-http-keep-alive-empty-line.mjs
@@ -0,0 +1,50 @@
1
+import * as common from '../common/index.mjs';
2
+import assert from 'node:assert';
3
+import { createServer } from 'node:http';
4
+import { connect } from 'node:net';
5
+
6
+const server = createServer({
7
+ connectionsCheckingInterval: 100,
8
+ headersTimeout: 100,
9
+ keepAliveTimeout: 300
10
+}, (req, res) => {
11
+ res.writeHead(404);
12
+ res.end();
13
14
+ req.socket.on('close', common.mustCall(() => {
15
+ server.close();
16
+ }));
17
+});
18
19
+server.listen(0, () => {
20
+ const client = connect({
21
+ host: 'localhost',
22
+ port: server.address().port,
23
+ }, () => {
24
+ client.write(
25
+ 'GET / HTTP/1.1\r\n' +
26
+ 'Host: localhost:3000\r\n' +
27
+ 'Content-Length: 0\r\n' +
28
+ '\r\n'
29
+ );
30
31
+ setTimeout(() => {
32
+ client.write('\r\n');
33
+ }, 100);
34
35
+ let responseBuffer = '';
36
37
+ client.on('data', (chunk) => {
38
+ responseBuffer += chunk.toString();
39
40
+ // Check if we've received the full header (ending with \r\n\r\n)
41
+ if (responseBuffer.includes('\r\n\r\n')) {
42
+ const statusLine = responseBuffer.split('\r\n')[0];
43
+ const status = statusLine.split(' ')[1];
44
+ assert.strictEqual(status, '404');
45
+ client.end();
46
+ }
47
+ });
48
+ client.on('end', common.mustCall());
49
50
0 commit comments