ModifyResponseGatewayFilter is not using newContentType from Config
Problem: I wanted to modify response body with changing Content-type, but probably SCG ignoring newContentType ModifyResponseGatewayFilter is not using newContentType in code as expected to set response 'Content-Type' header.
Don't see any usage of newContentType here: https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/factory/rewrite/ModifyResponseBodyGatewayFilterFactory.java#L91
SCG version 3.1.2
Example:
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("r1", r ->
r.path("/megatest")
.filters(gatewayFilterSpec -> {
return gatewayFilterSpec
.modifyResponseBody(c -> c
.setInClass(String.class)
.setOutClass(String.class)
.setNewContentType(MediaType.TEXT_PLAIN_VALUE)
.setRewriteFunction((exchange, o) -> Mono.just(((String) o).toUpperCase())))
.setPath("/target");
})
.uri("http://localhost:9999"))
.build();
}
Current behaviour: Response content-type is set from actual target response from external system. I'am not getting 'text/plain' as expected
Expected behaviour: Response content-type is set from newContentType field and equals 'text/plain'.
Further: I can manage to fix this problem after discussion.