-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
When I was using SseEventBuilder in spring mvc 5.3.x, I noticed that no spaces were added when constructing "data:" in the data method of the SseEventBuilderImpl implementation class. As a result, when the output is in markdown format, when the content that starts with a space appears in the segmented interception, the space will be lost on the front end. When reviewing the protocol standards of SSE, it was found that when a space appears after ":" in the content, the space is removed. See server-sent-events 9.2.6, which references
If the line starts with a U+003A COLON character (:)
Ignore the line.
If the line contains a U+003A COLON character (:)
Collect the characters on the line before the first U+003A COLON character (:), and let be that string.field
Collect the characters on the line after the first U+003A COLON character (:), and let be that string. If starts with a U+0020 SPACE character, remove it from .valuevaluevalue
So I suggest modifying append("data:") in the SseEventBuilderImpl.data method of spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java to append("data: "); The other versions are modified in the same way