Enable compression support via configuration
See original GitHub issueHey,
While trying to implement the spring-cloud gateway as a proxy to a JSON API i have the following scenario for a route:
.route(r -> r.path("/foo")
.filters(f -> f.stripPrefix(1).prefixPath("/bar").modifyResponseBody(List.class, List.class, (serverWebExchange, s) -> {
// add or remove some stuff from s here
return s;
}))
.uri("http://foo.bar")
)
However, with this default configuration i get the error:
org.springframework.core.codec.DecodingException: JSON decoding error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: UNKNOWN; line: 1, column: 2]
at org.springframework.http.codec.json.Jackson2Tokenizer.tokenize(Jackson2Tokenizer.java:103) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at reactor.core.publisher.FluxMapSignal$FluxMapSignalSubscriber.onNext(FluxMapSignal.java:137) ~[reactor-core-3.1.7.RELEASE.jar:3.1.7.RELEASE]
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108) ~[reactor-core-3.1.7.RELEASE.jar:3.1.7.RELEASE]
I suspect that this is because the answer comes back with content-type:application/json but also with content-encoding:gzip, however the filter only uses the content-type in selecting a HTTP reader. This results in the reader trying to parse the gzipped content as plain JSON, and failing.
Please modify the modifyResponseBody filter to take content-encoding into account or add a way to give parsing hints to the http reader. Looking at the source code i saw that there already are some hints, but are not used for this purpose at this time and they cannot be initialized from the modifyResponseBody
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Hi, same problem here, what I have done (but does not work):
In build.gradle:
implementation 'io.projectreactor.ipc:reactor-netty:0.7.15.RELEASE'
In java code: ` @Configuration public class NettyHttpClientConfiguration {
}`
When I try to run I get:
@EdgarsM do you know hoy to fix the httpClient bean duplicity? @primary is not working 😢
Any help would be appreciated.
Any leads on this issue? Getting same issue with Greenwich.SR3. Tried below in @Configuration but not effect -