Skip to content

Commit 8f7fcb0

Browse files
authored
Merge pull request http-party#791 from zbynek/headers
Make sure headers are not set twice on error
2 parents 9fd0d47 + f68e454 commit 8f7fcb0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/core/status-handlers.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ exports['416'] = (res, next) => {
5454
// flagrant error
5555
exports['500'] = (res, next, opts) => {
5656
res.statusCode = 500;
57-
res.setHeader('content-type', 'text/html');
57+
try {
58+
res.setHeader('content-type', 'text/html');
59+
} catch (e) {
60+
// errors may have triggered headers being sent already, make sure we don't hide the underlying error
61+
}
5862
const error = String(opts.error.stack || opts.error || 'No specified error');
5963
const html = `${[
6064
'<!doctype html>',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"man": "./doc/http-server.1",
3131
"engines": {
32-
"node": ">=12"
32+
"node": ">=12.16"
3333
},
3434
"contributors": [
3535
{

0 commit comments

Comments
 (0)