Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

const errOrEnd = common.mustSucceed(function(err) {
client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('end', errOrEnd);
client.on('error', errOrEnd);
}));

client.resume();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

const errOrEnd = common.mustSucceed(function(err) {
client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('end', errOrEnd);
client.on('error', errOrEnd);
}));

client.resume();
client.write('GET / HTTP/1.1\r\n');
Expand Down
24 changes: 13 additions & 11 deletions test/parallel/test-http-server-request-timeout-delayed-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
}));

client.resume();
client.write('POST / HTTP/1.1\r\n');
client.write('Host: example.com\r\n');
Expand All @@ -57,15 +70,4 @@ server.listen(0, common.mustCall(() => {
client.write('12345678901234567890\r\n\r\n');
}, common.platformTimeout(requestTimeout * 2)).unref();
});

const errOrEnd = common.mustSucceed(function(err) {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('end', errOrEnd);
client.on('error', errOrEnd);
}));
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

const errOrEnd = common.mustSucceed(function(err) {
client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('end', errOrEnd);
client.on('error', errOrEnd);
}));

client.resume();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

const errOrEnd = common.mustSucceed(function(err) {
client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('error', errOrEnd);
client.on('end', errOrEnd);
}));

client.resume();
client.write('POST / HTTP/1.1\r\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ server.listen(0, common.mustCall(() => {
response += chunk;
}));

const errOrEnd = common.mustSucceed(function(err) {
client.on('error', () => {
// Ignore errors like 'write EPIPE' that might occur while the request is
// sent.
});

client.on('close', common.mustCall(() => {
assert.strictEqual(
response,
'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n'
);
server.close();
});

client.on('end', errOrEnd);
client.on('error', errOrEnd);
}));

client.resume();
client.write('GET / HTTP/1.1\r\n');
Expand Down
Loading