Skip to content

Conversation

@jerolba
Copy link

@jerolba jerolba commented Nov 3, 2025

Fix #3948

Improves the media type comparison logic for determining when to use streaming response handling by implementing proper type and subtype matching instead of relying on exact media type equality.

This fix addresses scenarios where streaming responses include charset or other parameters in their Content-Type headers, ensuring they are properly handled with the streaming copy mechanism that includes appropriate flushing.

Problem

The previous implementation used List.contains() to check if a response's content type matches any of the configured streaming media types. This approach failed when the actual media type included parameters (e.g., text/event-stream;charset=UTF-8) because it relied on exact MediaType object equality rather than semantic type/subtype matching.

Solution

  • Replaced the direct contains() check with a new isStreamingMediaType() helper method
  • Implemented proper media type comparison using MediaType.equalsTypeAndSubtype()
  • Added comprehensive test coverage for media types with parameters

Replace List.contains() with equalsTypeAndSubtype() for more accurate
media type matching, avoiding issues with media type parameters.

Signed-off-by: jerolba <[email protected]>
@jerolba jerolba changed the title fix: improve media type comparison for streaming responses fix: improve media type comparison for streaming responses #3948 Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants