OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.42k stars 1.92k forks source link

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

Closed brennerm closed 1 year ago

brennerm commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

kdavisk6 commented 4 years ago

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

kdavisk6 commented 3 years ago

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.

ameenudheenirshad commented 3 years ago

Is there any workaround for this??

MazizEsa commented 3 years ago

@kdavisk6 still need help for this?

raphmello commented 3 years ago

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

Yerden01 commented 2 years ago

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 commented 2 years ago

Have the same problem

tcolombo08 commented 2 years ago

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

velo commented 2 years ago

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