spring-cloud-netflix: 411 Content Length required issue
For some reason, my home ISP throws 411 Content length required error when I try to post something to the cloud rest endpoint thru locally running zuul proxy.
So I tried setting content-length header manually from a custom filter like:
ctx.addZuulRequestHeader("content-length", ctx.getRequest().getHeader("Content-Length"));
But it throws
com.netflix.zuul.exception.ZuulException: Forwarding error...
Caused by: org.apache.http.ProtocolException: Content-Length header already present
at org.apache.http.protocol.RequestContent.process(RequestContent.java:95)
at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:131)
at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
I’m using Zuul 1.0.28. Am I doing anything wrong? I’m not even sure if the original problem would disappear if I manage to set this header manually. Any suggestion, anything would be very much appreciated.
p.s: ISP allows my post request when its done thru Feign.
This issue is originally posted at https://github.com/Netflix/zuul/issues/223.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27 (17 by maintainers)
Commits related to this issue
- Set entity contentLength for HttpClientRibbonCommand. If the content length isn't set on the entity, when http client determines which header to set, it sets transfer-encoding to chunked rather than ... — committed to spring-cloud/spring-cloud-netflix by spencergibb 8 years ago
- Set entity contentLength to 0 for GET requests. Zuul sets an empty entity for GET requests. The apache http client either sets transfer encoding to chunked or a content length header. This change set... — committed to spring-cloud/spring-cloud-netflix by spencergibb 8 years ago
- Set entity contentLength for HttpClientRibbonCommand. If the content length isn't set on the entity, when http client determines which header to set, it sets transfer-encoding to chunked rather than ... — committed to spring-cloud/spring-cloud-netflix by spencergibb 8 years ago
- Set entity contentLength to 0 for GET requests. Zuul sets an empty entity for GET requests. The apache http client either sets transfer encoding to chunked or a content length header. This change set... — committed to spring-cloud/spring-cloud-netflix by spencergibb 8 years ago
- Set entity contentLength to 0 for DELETE requests When there is no body in request and content-length is not set, apache http client sets transfer encoding to chunked. This change will set content-l... — committed to beatfreaker/spring-cloud-netflix by beatfreaker 3 years ago
@nissel I’ve since made changes that always propagate content-length: https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/support/ContextAwareRequest.java#L45
We’re fairly close to a 1.1.3. There won’t be any milestones or RC’s.