Package org.mockserver.fixture
Class SseBodyParser
- java.lang.Object
-
- org.mockserver.fixture.SseBodyParser
-
public class SseBodyParser extends Object
Parses rawtext/event-streambytes into a list ofSseEventobjects suitable for constructing anHttpSseResponse.The parser follows the SSE specification (W3C Server-Sent Events):
- Events are separated by blank lines (
\n\n) - Lines starting with
data:set the data field - Lines starting with
event:set the event type - Lines starting with
id:set the last event ID - Lines starting with
retry:set the reconnection time - Lines starting with
:are comments and are ignored - Multiple
data:lines within one event are joined with\n
Since per-chunk timestamps are not captured by the streaming relay, a fixed inter-event delay is applied to each event (except the first). The default is 50 milliseconds.
- Events are separated by blank lines (
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_INTER_EVENT_DELAY_MSDefault inter-event delay in milliseconds when per-chunk timestamps are not available.
-
Constructor Summary
Constructors Constructor Description SseBodyParser()Create a parser with the default inter-event delay.SseBodyParser(long interEventDelayMs)Create a parser with a custom inter-event delay.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<SseEvent>parse(String sseText)Parse raw SSE body text into a list ofSseEventobjects.
-
-
-
Field Detail
-
DEFAULT_INTER_EVENT_DELAY_MS
public static final long DEFAULT_INTER_EVENT_DELAY_MS
Default inter-event delay in milliseconds when per-chunk timestamps are not available.- See Also:
- Constant Field Values
-
-