Skip to content

Commit

Permalink
http: set rejectNonStandardBodyWrites option default to false
Browse files Browse the repository at this point in the history
  • Loading branch information
gerrard00 committed May 2, 2023
1 parent dd8ff7b commit 9c2e7da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
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

0 comments on commit 9c2e7da

Please sign in to comment.