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

Add support for testing SSE (Server-Sent Events) #116

Open
ashitaprasad opened this issue Feb 21, 2024 · 9 comments
Open

Add support for testing SSE (Server-Sent Events) #116

ashitaprasad opened this issue Feb 21, 2024 · 9 comments
Labels

Comments

@ashitaprasad
Copy link
Member

Tell us about the task you want to perform and are unable to do so because the feature is not available
SSE is gaining widespread popularity due to LLMs. We should support this feature.

See related discussion point 2 in #112

@ashitaprasad ashitaprasad added enhancement New feature or request good first issue Good for newcomers labels Feb 21, 2024
@mmjsmohit
Copy link
Contributor

Would like to start working on this issue.
The package I am planning to use for this is sse by the Dart Team.

Would update with the initial draft of the design sketch in sometime.

P.S. I am looking forward to following the same approach as in #258 and #215, hence would love to get some feedback on them!

@ashitaprasad
Copy link
Member Author

Sure @mmjsmohit.

@mmjsmohit
Copy link
Contributor

Here's the proposed the design sketch.

Untitled-2024-02-22-0219 (2)

@WrathOP
Copy link
Contributor

WrathOP commented Jan 5, 2025

Hi I was looking around for a package to support SSE but the flutter_client_sse No Web Support doesn't support web. The package mentioned by mmjsmohit sse is a dart team package and doesn't support flutter web either.
And there's another package event_source that doesn't work on web aswell.
Another interesting thread dart-lang/http#337

I guess we either need to implement our own. Or use conditional imports

@ashitaprasad
Copy link
Member Author

@WrathOP API Dash is only supported for the following platforms:
macOS, Windows, Linux, Android, iOS
We never had web support and adding it will require a lot of heavy lifting because it will require a proxy server in the middle to perform all requests and just display results on the browser.

@WrathOP
Copy link
Contributor

WrathOP commented Jan 13, 2025

Here's the proposed the design sketch.

Untitled-2024-02-22-0219 (2)

Do we make sse a seperate APIType or just handle it in the http type when the header contains text/event-stream and we just keep the connection alive and showing the list of all the events incoming.

@ashitaprasad
Copy link
Member Author

Here's the proposed the design sketch.

Untitled-2024-02-22-0219 (2)

The image is not opening. Please drag and drop it properly in the comments.

Do we make sse a seperate APIType or just handle it in the http type when the header contains text/event-stream and we just keep the connection alive and showing the list of all the events incoming.

text/event-stream in the header helps identify the request as an SSE, but the whole catch is how can you obtain the header before you start receiving the response content. If we know the API Type before hand we can handle response accordingly.

Screenshot 2025-01-13 at 7 34 23 PM
  1. Replied above
  2. http also has a streamed response feature you can check it out. flutter_client_sse is built on top of http. There is also https://pub.dev/packages/sse

@WrathOP
Copy link
Contributor

WrathOP commented Jan 13, 2025

Here's the proposed the design sketch.

Untitled-2024-02-22-0219 (2)

The image is not opening. Please drag and drop it properly in the comments.

Do we make sse a seperate APIType or just handle it in the http type when the header contains text/event-stream and we just keep the connection alive and showing the list of all the events incoming.

text/event-stream in the header helps identify the request as an SSE, but the whole catch is how can you obtain the header before you start receiving the response content. If we know the API Type before hand we can handle response accordingly.

Screenshot 2025-01-13 at 7 34 23 PM 1. Replied above 2. http also has a streamed response feature you can check it out. flutter_client_sse is built on top of http. There is also https://pub.dev/packages/sse

image
It was the same image from above.

Ok The fact that user can use normal http and still receive a text/event-stream do we then switch him to sse type of api? or we just throw an error ? or just return the first event and close the stream?

I was thinking of using http package with streamedResponse only and that sse package is build for a specification of a backend and frontend only and not a general propose package.

So finally we are making a different api type and doing it that way not based on the response headers.

@ashitaprasad
Copy link
Member Author

ashitaprasad commented Jan 14, 2025

Ok The fact that user can use normal http and still receive a text/event-stream do we then switch him to sse type of api? or we just throw an error ? or just return the first event and close the stream?

In this case whatever is the default behaviour of http get/post/etc. will happen. Will require no changes in API Dash.
User will not be forced to switch to SSE type.

I was thinking of using http package with streamedResponse only and that sse package is build for a specification of a backend and frontend only and not a general propose package.

ok. take your call what is best for the project.

So finally we are making a different api type and doing it that way not based on the response headers.

cool

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