Class SseAwareExpectationConverter

java.lang.Object
org.mockserver.fixture.SseAwareExpectationConverter

public class SseAwareExpectationConverter extends Object
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-streamed header being present (set by the streaming relay)
  • The Content-Type header containing text/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 Details

    • SseAwareExpectationConverter

      public SseAwareExpectationConverter()
    • SseAwareExpectationConverter

      public SseAwareExpectationConverter(long interEventDelayMs)
  • Method Details

    • convert

      public Expectation[] convert(Expectation[] expectations)
      Convert an array of expectations, making streaming responses SSE-aware.
      Parameters:
      expectations - the recorded expectations
      Returns:
      expectations with SSE responses where applicable