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

SSE doesn't output error bodies, just spaces #2480

Open
byteit101 opened this issue Sep 19, 2022 · 0 comments
Open

SSE doesn't output error bodies, just spaces #2480

byteit101 opened this issue Sep 19, 2022 · 0 comments
Assignees
Labels

Comments

@byteit101
Copy link

Describe the bug
SSE transport doesn't allow error bodies to be written, unlike other transports:

(Full source based on samples used in the curl requests is at https://gist.github.com/byteit101/63c5fe645cbfa7e2222948bd77e72d51 )

		if (r.transport() != TRANSPORT.SSE)
			return Response.status(Status.BAD_REQUEST).entity("SSE is the only thing supported").build();
		else
			return Response.status(451).entity("{my-error-body}").build();

Atmosphere Info

  • version 2.7.7

Expected behavior
long-polling (actual, correct):

$ curl -s -i -X GET 'http://localhost:8080/chat/the/sse/error' -H 'Accept: text/event-stream,application/json'                           
HTTP/1.1 400 Bad Request
(snip)
Content-Length: 31

SSE is the only thing supported%
$ 

SSE (theoretical response):

$ curl -s -i -X GET 'http://localhost:8080/chat/the/sse/error?X-Atmosphere-Transport=sse' -H 'Accept: text/event-stream,application/json'
HTTP/1.1 451 
(snip)
Content-Length: 15

{my-error-body}%
$

Actual behavior
SSE:

$ curl -s -i -X GET 'http://localhost:8080/chat/the/sse/error?X-Atmosphere-Transport=sse' -H 'Accept: text/event-stream,application/json'
HTTP/1.1 451 
(snip)
Content-Length: 15

               %
$

Interestingly, the length (and number of spaces) is the correct size. Note I used the terminal garbage % to show the end of line as there was no newline.

Systems (please complete the following information):

  • OS: linux x64
  • Browser name and version: N/A
  • Java version and distribution: OpenJDK 1.8 && 11
  • Server name and version: Jetty

Additional context
A "normal" sse call has lots of spaces, I'm not sure if it's relevant but I noticed it:

$ curl -s -i -X GET 'http://localhost:8080/chat/the/sse/normal?X-Atmosphere-Transport=sse' -H 'Accept: text/event-stream,application/json'
HTTP/1.1 200 OK
(snip)
Transfer-Encoding: chunked

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
data:suspend

data:X

^C
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants