AbstractProxyExchange takes into account MediaType parameters
Describe the bug
AbstractProxyExchange compares response MediaType with configured StreamingMediaTypes using equals method that takes into account MediaType parameters.
In this code:
if (properties.getStreamingMediaTypes().contains(clientResponse.getHeaders().getContentType())) {
a response with content type text/event-stream;charset=utf-8 is not considered as a streaming media type
A better way of comparing MediaType without considering parameters is using MediaType::equalsTypeAndSubtype method.
The code can be changed to something like this:
if (isStreamingMediaType(clientResponse.getHeaders().getContentType())) {
implementing a new method:
private boolean isStreamingMediaType(MediaType mediaType) {
return properties.getStreamingMediaTypes().stream().anyMatch(streameable -> streamable.equalsTypeAndSubtype(mediaType));
}
The specification of Server-Sent Events implicitly states that the ContentType is text/event-stream and that the charset is UTF-8, but some servers are including it explicitly in their response, breaking the streaming feature in Spring Cloud Gateway.
Sample No