Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.
Spring Cloud Hoxton.SR10 Spring Boot 2.3.9.RELEASE
Zuul adds "Transfer-Encoding: chunked" header to the DELETE request which we don't expect in the DELETE requests: they should not have body so "Transfer-Encoding" is redundant.
Delete request is as simple as this: curl --location --request DELETE 'zuul_url'
Neither header "Transfer-Encoding" nor "Content-Length" headers were present in DELETE request before it is proxied from client to the service by Zuul.
Moreover, since I'm using Payara application server for deploying my service, it throws me 400 BAD_REQUEST due to the presence of "Transfer-Encoding: chunked" header.
Comment From: iburakov
Faced the same problem (independently, in a different project).
After several hours of debugging, I can say that nothing is setting the Transfer-Encoding header in Zuul / Hystrix / Ribbon code. org.apache.http.protocol.RequestContent is a "culprit".
It's even casually mentioned in a comment deep inside spring-cloud-netflix-ribbon:
https://github.com/spring-cloud/spring-cloud-netflix/blob/92cb1a7aa0471cc3286b9936511dd5f12ff6cdca/spring-cloud-netflix-ribbon/src/main/java/org/springframework/cloud/netflix/ribbon/apache/RibbonApacheHttpRequest.java#L62-L71
I'd be glad if someone explained the reason why they do so. OkHttp seem to behave the same way. WildFly doesn't treat DELETE requests with "transfer-encodning: chunked" as bad after all, so it may be an issue for Payara.
There's a fix for "GET" method present in the RibbonApacheHttpRequest though. Should it be applied for all methods without body?
At this point, workaround is to explicitly set the Zuul request Content-Length to 0 somehow (is it possible with a "pre" filter?) or to switch to the deprecated Ribbon RestClient by setting property ribbon.restclient.enabled to true.
Comment From: spencergibb
PRs welcome
Comment From: OlgaMaciaszek
Fixed.