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

Default Client does not include Content-Length header for POST with Empty Body #1229

Closed
brennerm opened this issue May 19, 2020 · 11 comments · Fixed by #1778
Closed

Default Client does not include Content-Length header for POST with Empty Body #1229

brennerm opened this issue May 19, 2020 · 11 comments · Fixed by #1778
Labels
bug Unexpected or incorrect behavior help wanted Issues we need help with tackling

Comments

@brennerm
Copy link

brennerm commented May 19, 2020

We are using Feign 10.7.4 to execute a POST request with an empty body. In this case Feign does not add a Content-Length header to the request. According to the HTTP specification this is fine but some proxies, in our case Azure API Management, do not accept POST request with no Content-Length header. Would it be possible to add a Content-Length: 0 header to PATCH, POST and PUT requests with an empty body?

Further context:

@velo
Copy link
Member

velo commented May 19, 2020

Should be a simple change around this
https://github.com/OpenFeign/feign/blob/master/core/src/main/java/feign/Client.java#L189

What client are you using? Default one? if so, i gave you the correct link.

@brennerm
Copy link
Author

We are including spring-cloud-openfeign so I suppose we use the FeignBlockingLoadBalancerClient client class.

@kdavisk6
Copy link
Member

@brennerm can you please confirm with the Spring Cloud team that they are passing this through to us first?

@kdavisk6 kdavisk6 added the feedback provided Feedback has been provided to the author label May 30, 2020
@kdavisk6
Copy link
Member

In this case, only the default Client implementation is out of compliance. I'm going to update the title of this issue to reference that class and mark this as a bug.

@kdavisk6 kdavisk6 changed the title No Content-Length header for POST request with an empty body Default Client does not include Content-Length header for POST with Empty Body Dec 29, 2020
@kdavisk6 kdavisk6 added bug Unexpected or incorrect behavior help wanted Issues we need help with tackling and removed feedback provided Feedback has been provided to the author labels Dec 29, 2020
@ameenudheenirshad
Copy link

Is there any workaround for this??

@MazizEsa
Copy link

@kdavisk6 still need help for this?

@raphmello
Copy link

I had the same problem, and solved sending an empty string.

@Yerden01
Copy link

Yerden01 commented Nov 1, 2021

If you are using POST/PUT method with RequestParam, instead of this, try using Request body, cause with empty body Feign Client will send Content-Length: 0, and you will face "Length Required" problem

@alexey-plotnikoff
Copy link

Have the same problem

@tcolombo08
Copy link

Also having this issue. Any idea on an ETA of a fix?

@velo
Copy link
Member

velo commented Jul 11, 2022

hi @tcolombo08 feign is mainly driven by volunteer work. ETA depends on someone that is affected by this issue getting involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior help wanted Issues we need help with tackling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants