From 3f1f15d3ecaaea259859d1dea45c9a5547bbec82 Mon Sep 17 00:00:00 2001 From: Gerrard Lindsay Date: Tue, 2 May 2023 14:20:48 -0400 Subject: [PATCH] http: set rejectNonStandardBodyWrites option default to false --- lib/_http_server.js | 2 +- .../test-http-head-throw-on-response-body-write.js | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index b2cce201009c52..d55ee98ec2d4a8 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -490,7 +490,7 @@ function storeHTTPOptions(options) { validateBoolean(rejectNonStandardBodyWrites, 'options.rejectNonStandardBodyWrites'); this.rejectNonStandardBodyWrites = rejectNonStandardBodyWrites; } else { - this.rejectNonStandardBodyWrites = true + this.rejectNonStandardBodyWrites = false } } diff --git a/test/parallel/test-http-head-throw-on-response-body-write.js b/test/parallel/test-http-head-throw-on-response-body-write.js index 6c3c3cf9f52e50..7352b20d84df6e 100644 --- a/test/parallel/test-http-head-throw-on-response-body-write.js +++ b/test/parallel/test-http-head-throw-on-response-body-write.js @@ -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);