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

@@ -147,7 +147,13 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
for (String line : lines) {
if (line.startsWith("data:")) {
data = (data != null ? data : new StringBuilder());
data.append(line.substring(5).trim()).append('\n');
if (line.charAt(5) != ' ') {
data.append(line, 5, line.length());
}
else {
data.append(line, 6, line.length());
}
data.append('\n');
}
if (shouldWrap) {
if (line.startsWith("id:")) {