Skip to content

SseEventBuilder implementation is not standards compliant #33963

@leon2LF

Description

@leon2LF

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions