Skip to content

Commit

Permalink
Remove charset in tests (#3807)
Browse files Browse the repository at this point in the history
* removed charset setting when setting default header

* Remove charset from tests

Co-authored-by: mpark86 <dev.minuk.park@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
Co-authored-by: Pilot <timemachine@ctrl-c.club>
  • Loading branch information
4 people committed May 21, 2021
1 parent 3958e9f commit dbc634c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/defaults.js
Expand Up @@ -57,7 +57,7 @@ var defaults = {
return data.toString();
}
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
setContentTypeIfUnset(headers, 'application/json');
return JSON.stringify(data);
}
return data;
Expand Down
2 changes: 1 addition & 1 deletion test/specs/headers.spec.js
Expand Up @@ -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();
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/unit/adapters/http.js
Expand Up @@ -124,7 +124,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) {
Expand All @@ -142,7 +142,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]));
Expand Down Expand Up @@ -247,7 +247,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 () {
Expand All @@ -262,7 +262,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 () {
Expand Down

0 comments on commit dbc634c

Please sign in to comment.