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

Axios added duplicated content-length header when request already has a content-length header #2107

Closed
XiaoningLiu opened this issue Apr 22, 2019 · 0 comments

Comments

@XiaoningLiu
Copy link

Describe the bug
Axios is a promise based HTTP client with browser and Node.js support. As an HTTP client, Axios wants to make sure the sent message contains a proper content-length header as well. So it includes a number type “Content-Length” header by default. This behavior can be observed in /node_modules/axios/lib/adapters/http.js, at line 45.

If request already has a lowercase "content-length" header, since they have different casing, the header included by Axios does not overwrite the one included by the request. So we’re sending two “content-length” headers to the server (same values and different types). I believe this is not the expected behavior we want.

Expected behavior

Before set content-length header, Axios should check if there is a case insensitive "content-length" header.

IF THERE IS AN EXISTING CONTENT-LENGTH HEADER:
COMPARE WITH CONTENT-LENGTH CALCULATED
IF DISMATCH
THROW ERROR
ELSE
SET CONTENT-LENGTH HEADER IN AXIOS

Environment:

  • Axios Version 0.18.0
  • OS: Any
  • Node.js: Any
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