spring-cloud/spring-cloud-netflix

Only request bodies with content-type multipart/* and application/x-www-form-urlencoded work

Open

#3,418 opened on Mar 14, 2019

View on GitHub
 (13 comments) (0 reactions) (0 assignees)Java (2,433 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,805 stars)
PR merge metrics
 (Avg merge 2d 6h) (5 merged PRs in 30d)

Description

Make a request through zuul using a POST or PUT verb with a content-type that is not multipart/* or application/x-www-form-urlencoded`

When Zuul makes the request to the backend, it won't include the request body.

The reason is that the original request body is consumed in org.springframework.cloud.netflix.zuul.filters.TraceProxyRequestHelper.debug(String, String, MultiValueMap<String, String>, MultiValueMap<String, String>, InputStream) leaving no request body to consume when org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter actually sends the request.

Requests of content-type application/x-www-form-urlencoded work because org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter gets the body. Requests of type multipart/* work because org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper.shouldDebugBody(RequestContext) explicitly excludes them.

To reproduce the issue, just make a request through zuul with a Content-Type of text/plain, for example, and you'll always get a time out error as the backend server will keep waiting for response body that it will never get.

I believe this issue was originally reported at https://github.com/spring-cloud/spring-cloud-netflix/issues/2610

Contributor guide