From 164b3eb1a246abc275342f078a70e2d04cdb907c Mon Sep 17 00:00:00 2001 From: mpark86 Date: Fri, 13 Dec 2019 16:34:33 -0500 Subject: [PATCH 1/2] removed charset setting when setting default header --- lib/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/defaults.js b/lib/defaults.js index 23e1cbd22a..3525db548a 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -48,7 +48,7 @@ var defaults = { return data.toString(); } if (utils.isObject(data)) { - setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + setContentTypeIfUnset(headers, 'application/json'); return JSON.stringify(data); } return data; From a8bc886190b2962daad8de67ae8b3391fcec2100 Mon Sep 17 00:00:00 2001 From: Pilot Date: Thu, 20 May 2021 22:53:55 -0400 Subject: [PATCH 2/2] Remove charset from tests --- test/specs/headers.spec.js | 2 +- test/unit/adapters/http.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/specs/headers.spec.js b/test/specs/headers.spec.js index c9c768def2..c1d10d7b89 100644 --- a/test/specs/headers.spec.js +++ b/test/specs/headers.spec.js @@ -90,7 +90,7 @@ describe('headers', function () { }); getAjaxRequest().then(function (request) { - testHeaderValue(request.requestHeaders, 'Content-Type', 'application/json;charset=utf-8'); + testHeaderValue(request.requestHeaders, 'Content-Type', 'application/json'); done(); }); }); diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 497eb28f73..abf36f9cac 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -65,7 +65,7 @@ describe('supports http with nodejs', function () { }; server = http.createServer(function (req, res) { - res.setHeader('Content-Type', 'application/json;charset=utf-8'); + res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(data)); }).listen(4444, function () { axios.get('http://localhost:4444/').then(function (res) { @@ -83,7 +83,7 @@ describe('supports http with nodejs', function () { }; server = http.createServer(function (req, res) { - res.setHeader('Content-Type', 'application/json;charset=utf-8'); + res.setHeader('Content-Type', 'application/json'); var bomBuffer = Buffer.from([0xEF, 0xBB, 0xBF]) var jsonBuffer = Buffer.from(JSON.stringify(data)); res.end(Buffer.concat([bomBuffer, jsonBuffer])); @@ -188,7 +188,7 @@ describe('supports http with nodejs', function () { zlib.gzip(JSON.stringify(data), function (err, zipped) { server = http.createServer(function (req, res) { - res.setHeader('Content-Type', 'application/json;charset=utf-8'); + res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Encoding', 'gzip'); res.end(zipped); }).listen(4444, function () { @@ -203,7 +203,7 @@ describe('supports http with nodejs', function () { it('should support gunzip error handling', function (done) { server = http.createServer(function (req, res) { - res.setHeader('Content-Type', 'application/json;charset=utf-8'); + res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Encoding', 'gzip'); res.end('invalid response'); }).listen(4444, function () {