You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ServerSentEventHttpMessageReader does not recognize data fields without a colon #37461
ServerSentEventHttpMessageReader does not recognize SSE data fields when the colon is omitted:
id:c42
event:foo
data
data
or
id:c42
event:foo
data
According to the WHATWG HTML specification, a line without a colon must be processed as a field name with an empty value.
Therefore, data and data: should be treated equivalently.
Reproducible test case:
@Test
void readServerSentEventsDataWithoutColon() {
// given
ServerSentEventHttpMessageReader reader = new ServerSentEventHttpMessageReader();
String body = """
id:c42
event:foo
data
data
""";
MockServerHttpRequest request = MockServerHttpRequest.post("/")
.body(body);
// when
Flux<ServerSentEvent> events = reader.read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class), request, Collections.emptyMap())
.cast(ServerSentEvent.class);
// then - fails
StepVerifier.create(events)
.expectNext(ServerSentEvent.builder()
.id("c42")
.event("foo")
.data("\n")
.build())
.expectComplete()
.verify();
}
Expected behavior
The reader should follow the WHATWG SSE parsing algorithm: data\ndata should produce an event with data("\n"), just like data:\ndata:
Actual behavior
The implementation only handles data fields that start with data: data\ndata produce an event with data(null)
Activity