-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Only request bodies with content-type multipart/* and application/x-www-form-urlencoded work #3418
Comments
I'm unable to reproduce this with a POST with text/plain. Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file. |
My apologies if this isn't that completely minimal, but it does reproduce the problem and it's really easy to run. Grab this: And run: See the problem with: Now see how the problem is fixed by editing and trying that same curl command again. |
I'm going to ask that you spend some time making a minimal app I can use. |
The problem is that the request's InputStream is being read multiple times which doesnt' work as Zuul is expecting unless the request is wrapped to specifically implement that behavior. Zuul is expecting to call If the request's content type is If the request's content contains "multipart", see https://github.com/spring-cloud/spring-cloud-netflix/blob/v2.1.1.RELEASE/spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelper.java#L273, then Zuul doesn't debug it, avoiding this issue. So if the content type isn't |
I understand your reasoning but was unable to replicate the described behaviour with a minimal app. I couldn't get your app to behave
|
Here's a minimal app: https://www.integralblue.com/zuul3418-2.tar.gz I've found that this issue is only reproducible when |
Tracing a bit, I noticed that when this occurs, at https://github.com/spring-cloud/spring-cloud-netflix/blob/v2.1.1.RELEASE/spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/Servlet30WrapperFilter.java#L74 One solution would be to change this method to remove the |
If it only happens with Removing the call to |
I think those reasons are covered in #2887 I like the idea of not buffering, don't get me wrong - but I also want to work :) Perhaps the buffering decision can be made based on the value of the |
I'm not keen to add make a buffering decision based off of something that historically hasn't had anything to do with buffering. So far the only user of |
That seems reasonable. Should trace request body be off by default always? On a related note, https://github.com/spring-cloud/spring-cloud-netflix/blob/2.0.x/spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/Servlet30WrapperFilter.java has this comment:
and its class level javadocs is:
Since spring-cloud-netflix-zuul runs on Spring Boot 2.0, and Spring Boot 2.0 requires Servlet 3.1 (see https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/html/getting-started-system-requirements.html), it seems that filter should either be removed (since it's no longer necessary), renamed, or its use replaced by using Spring's |
Probably, but we won't be making a breaking change anymore. The problem was the zuul |
After thinking about it, I'd be ok making this change for Hoxton (2.2.x) |
traceRequestBody requires the body to be buffered which reduces performance and can be problematic, such as when used in combination with `zuul.use-filter=true` and `zuul.servlet-path=/` See spring-cloud#3418 traceRequestBody should only be set when logging the request body is actually necessary.
Request body tracing reads the body then it will be read again later for actual handling. Therefore, request buffering is required when request body tracing. Fixes spring-cloud#3418
traceRequestBody requires the body to be buffered which reduces performance and can be problematic, such as when used in combination with `zuul.use-filter=true` and `zuul.servlet-path=/` See spring-cloud#3418 traceRequestBody should only be set when logging the request body is actually necessary.
traceRequestBody requires the body to be buffered which reduces performance and can be problematic, such as when used in combination with `zuul.use-filter=true` and `zuul.servlet-path=/` See #3418 traceRequestBody should only be set when logging the request body is actually necessary.
Make a request through zuul using a
POST
orPUT
verb with a content-type that is notmultipart/* 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 whenorg.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter
actually sends the request.Requests of content-type
application/x-www-form-urlencoded
work becauseorg.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter
gets the body. Requests of typemultipart/*
work becauseorg.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 #2610
The text was updated successfully, but these errors were encountered: