Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
http: set rejectNonStandardBodyWrites option default to false
  • Loading branch information
gerrard00 committed May 2, 2023
commit 9c2e7daabc0a7f883c8b610d074f23c438f25cc0
2 changes: 1 addition & 1 deletion lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function OutgoingMessage(options) {

this[kErrored] = null;
this[kHighWaterMark] = options?.highWaterMark ?? getDefaultHighWaterMark();
this[kRejectNonStandardBodyWrites] = options?.rejectNonStandardBodyWrites ?? true;
this[kRejectNonStandardBodyWrites] = options?.rejectNonStandardBodyWrites ?? false;
}
ObjectSetPrototypeOf(OutgoingMessage.prototype, Stream.prototype);
ObjectSetPrototypeOf(OutgoingMessage, Stream);
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function storeHTTPOptions(options) {
validateBoolean(rejectNonStandardBodyWrites, 'options.rejectNonStandardBodyWrites');
this.rejectNonStandardBodyWrites = rejectNonStandardBodyWrites;
} else {
this.rejectNonStandardBodyWrites = true
this.rejectNonStandardBodyWrites = false
}
}

Expand Down
11 changes: 2 additions & 9 deletions test/parallel/test-http-head-throw-on-response-body-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');

// should be using common.mustCall on both req res callbacks provided to createServer
{
const server = http.createServer((req, res) => {
assert.throws(() => {
res.write('this is content');
}, {
code: 'ERR_HTTP_BODY_NOT_ALLOWED',
name: 'Error',
message: 'Adding content for this request method or response status is not allowed.'
});
res.end();
res.writeHead(200);
res.end('this is content');
});
server.listen(0);

Expand Down