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

MockWebServer: streaming response (SSE) #2894

Closed
artem-zinnatullin opened this issue Oct 6, 2016 · 3 comments
Closed

MockWebServer: streaming response (SSE) #2894

artem-zinnatullin opened this issue Oct 6, 2016 · 3 comments

Comments

@artem-zinnatullin
Copy link
Contributor

I might be wrong, but looks like MockWebServer does not allow "endless" responses controlled by writing to body Buffer.

I'm trying to simulate Server Sent Events with setting Buffer as a body of MockResponse and keep connection open via not closing the Buffer. But whatever I do MockWebServer closes connection for me and does not allow me emulate SSE.

Basically, I'd like to keep connection until I explicitly close() body Buffer and be able to write data to socket via writing to body Buffer.

What about adding such API to MockResponse? i.e. MockResponse.setStreamingBody(Buffer body).

@JakeWharton
Copy link
Collaborator

Buffer is not safe for use across threads and it's unclear what MWS would be doing during this. Just spinning in a hot loop or waiting for a notification? We don't have a good type to model this and it would probably need something more sophisticated like RequestBody which can block on the writer thread or web sockets which have their own API.

@swankjesse
Copy link
Collaborator

Tracking as #2916

@artem-zinnatullin
Copy link
Contributor Author

Right, Buffer requires some wrapper to make it thread safe + add push/pull based API. I'll track #2916 then, thanks.

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

No branches or pull requests

3 participants