Remove only leading space for SSE data

Prior to this commit, all white space was trimmed from Server Sent Event
data. After this commit, only a leading space is removed (if present).

Closes gh-27473
This commit is contained in:
Arjen Poutsma
2021-09-28 14:56:39 +02:00
parent 85bdea6f47
commit 3be2b32e21
2 changed files with 21 additions and 1 deletions

View File

@@ -138,6 +138,20 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
.verify();
}
@Test
public void trimWhitespace() {
MockServerHttpRequest request = MockServerHttpRequest.post("/")
.body(Mono.just(stringBuffer("data: \tfoo \ndata:bar\t\n\n")));
Flux<String> data = reader.read(ResolvableType.forClass(String.class),
request, Collections.emptyMap()).cast(String.class);
StepVerifier.create(data)
.expectNext("\tfoo \nbar\t")
.expectComplete()
.verify();
}
@Test
public void readPojo() {
MockServerHttpRequest request = MockServerHttpRequest.post("/")