Skip to content

Commit 9c2e7da

Browse files
committed
http: set rejectNonStandardBodyWrites option default to false
1 parent dd8ff7b commit 9c2e7da

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

lib/_http_outgoing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function OutgoingMessage(options) {
152152

153153
this[kErrored] = null;
154154
this[kHighWaterMark] = options?.highWaterMark ?? getDefaultHighWaterMark();
155-
this[kRejectNonStandardBodyWrites] = options?.rejectNonStandardBodyWrites ?? true;
155+
this[kRejectNonStandardBodyWrites] = options?.rejectNonStandardBodyWrites ?? false;
156156
}
157157
ObjectSetPrototypeOf(OutgoingMessage.prototype, Stream.prototype);
158158
ObjectSetPrototypeOf(OutgoingMessage, Stream);

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ function storeHTTPOptions(options) {
490490
validateBoolean(rejectNonStandardBodyWrites, 'options.rejectNonStandardBodyWrites');
491491
this.rejectNonStandardBodyWrites = rejectNonStandardBodyWrites;
492492
} else {
493-
this.rejectNonStandardBodyWrites = true
493+
this.rejectNonStandardBodyWrites = false
494494
}
495495
}
496496

test/parallel/test-http-head-throw-on-response-body-write.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ const common = require('../common');
2424
const assert = require('assert');
2525
const http = require('http');
2626

27-
// should be using common.mustCall on both req res callbacks provided to createServer
2827
{
2928
const server = http.createServer((req, res) => {
30-
assert.throws(() => {
31-
res.write('this is content');
32-
}, {
33-
code: 'ERR_HTTP_BODY_NOT_ALLOWED',
34-
name: 'Error',
35-
message: 'Adding content for this request method or response status is not allowed.'
36-
});
37-
res.end();
29+
res.writeHead(200);
30+
res.end('this is content');
3831
});
3932
server.listen(0);
4033

0 commit comments

Comments
 (0)