Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading whitespaces are removed while reading SSE response #27473

Closed
yunjae2 opened this issue Sep 27, 2021 · 2 comments
Closed

Leading whitespaces are removed while reading SSE response #27473

yunjae2 opened this issue Sep 27, 2021 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@yunjae2
Copy link

yunjae2 commented Sep 27, 2021

Affects: 5.3.10.RELEASE and current main (30efa4d)


I'm making a SSE request to another server using WebClient w/ WebFlux, and the response from the WebClient always shows the results with leading whitespaces removed as well as trailing ones.
I think it is due to ServerSentEventHttpMessageReader::buildEvent trimming every line:

data.append(line.substring(5).trim()).append('\n');

Is there any reason that leading whitespaces must be removed from the SSE response data?
I wanted to use tabs at the start of each line to indent the text.
I've tried other clients like curl but they show responses with the leading whitespaces preserved.
Thanks in advance.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 27, 2021
@poutsma poutsma self-assigned this Sep 28, 2021
@poutsma poutsma added type: bug A general bug in: web Issues in web modules (web, webmvc, webflux, websocket) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 28, 2021
@poutsma
Copy link
Contributor

poutsma commented Sep 28, 2021

The spec says the following, under "If the line contains a U+003A COLON character (:)"

If value starts with a U+0020 SPACE character, remove it from value.

So it appears that using trim() is a bit too aggressive here, and should only remove the first space (if any); nothing more. I am working on a fix.

@poutsma
Copy link
Contributor

poutsma commented Sep 28, 2021

Related issue: #22043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants