Package org.mockserver.fixture
Class SseAwareExpectationConverter
java.lang.Object
org.mockserver.fixture.SseAwareExpectationConverter
Converts a recorded
Expectation (from a FORWARDED_REQUEST log entry) into an
SSE-aware replay expectation when the forwarded response was a streaming response.
Detection is based on:
- The
x-mockserver-streamedheader being present (set by the streaming relay) - The
Content-Typeheader containingtext/event-stream
When a streaming response is detected and the capture was not truncated, the response body
is parsed into SseEvent objects and the expectation's response action is replaced
with an HttpSseResponse.
When the capture was truncated (x-mockserver-stream-truncated header present),
the expectation falls back to a static response with a warning header, since the SSE body
is incomplete and cannot produce a correct replay.
Non-streaming expectations are returned unchanged.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(Expectation[] expectations) Convert an array of expectations, making streaming responses SSE-aware.
-
Constructor Details
-
SseAwareExpectationConverter
public SseAwareExpectationConverter() -
SseAwareExpectationConverter
public SseAwareExpectationConverter(long interEventDelayMs)
-
-
Method Details
-
convert
Convert an array of expectations, making streaming responses SSE-aware.- Parameters:
expectations- the recorded expectations- Returns:
- expectations with SSE responses where applicable
-