Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.21.3 does not set charset in Content-Type header #4016

Closed
ddolcimascolo opened this issue Sep 5, 2021 · 3 comments
Closed

v0.21.3 does not set charset in Content-Type header #4016

ddolcimascolo opened this issue Sep 5, 2021 · 3 comments

Comments

@ddolcimascolo
Copy link

ddolcimascolo commented Sep 5, 2021

Describe the bug

Axios 0.21.3 (0.21.2 too, actually) does not set chartset=utf-8 in Content-Type header on POST requests, using an object as data

To Reproduce

I've created a Runkit: https://runkit.com/ddolcimascolo/axios-0.21.3-content-type-issue

const http = require("http"),
      axios0_21_3 = require('axios@0.21.3'),
      axios0_21_1 = require('axios@0.21.1');

function doPOSTRequest(axios, version) {
  return axios({
    method: 'post',
    url: 'http://127.0.0.1:8080',
    data: { my: 'object' }
  })
    .then(res => console.log(`Content-Type with v${version}: ${res.data['content-type']}`));
}

const server = http
  .createServer((req, res) => {
    res.write(JSON.stringify(req.headers));
    res.end();
  })
  .listen(8080, async() => {
    await doPOSTRequest(axios0_21_1, '0.21.1');
    await doPOSTRequest(axios0_21_3, '0.21.3');
    
    server.close();
  });

This code will yield

"Content-Type with v0.21.1: application/json;charset=utf-8"
"Content-Type with v0.21.3: application/json"

Expected behavior

Content-Type header should contain charset=utf-8

Environment

  • Axios Version [0.21.3]
  • Adapter [HTTP]
  • Browser [N/A]
  • Browser Version [N/A]
  • Node.js Version [14]
  • OS: [Ubuntu 20.04]
  • Additional Library Versions [None]

Additional context/Screenshots

N/A

@ddolcimascolo
Copy link
Author

OK, I just found #2154 that is actually mentioned in 0.21.2 changelog. I've missed it the first time because it's in "Internal/Tests" section.

IMHO it's not OK to "hide" this in the "Internal" section. It's not an internal change at all, it's a breaking change in Axios behavior. At least you should have mentioned it in a "Breaking changes" section, and even better you should not have released a patch version... I know you're still in 0.x so you can break stuff, etc. but Axios is a lib used by hundreds of projects and breaking things is not cool.

@jasonsaayman
Copy link
Member

@ddolcimascolo Sorry about this, I know some things may have fallen through the cracks, this was a release that spanned almost a year so not everything was fresh in my mind. We did not intentionally hide this, in fact I did not think that this was a largely impactful change, I will try be more cognisant of this in the future.

@ddolcimascolo
Copy link
Author

I know @jasonsaayman. No worries

Thx for maintaining Axios!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants