-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: CapacitorHttp - No support for Server-Sent Events (EventSource API) #6582
Comments
I tried to use https://github.com/Azure/fetch-event-source to get a |
I'd like to kindly request the Ionic team to consider adding support for the |
@youngerjo the type is not enough. the entire http client needs to be restructured to support streaming data. I wonder if they should adopt OkHttp instead of trying to write it themselves |
@jrobeson Thanks for pointing that out. For the time being, I might lean towards using the web fetch method for streaming responses. My main concern with that approach is the limitation of not being able to include an authorization header due to CORS restrictions. I genuinely hope the team considers restructuring the http client or integrating a more efficient solution like OkHttp in the future. |
Yeah, CORS has also been the main problem with our app just using native fetch. For just HTTP with simple content-types like |
In #5145 (comment), nothing was said about SSE and it may be that it was simply forgotten at the time or there were other reasons why it was not included in @thomasvidas, can you tell us whether SSE was even planned or whether it is even possible to include this? Especially for mobile applications, SSE is a much more energy-saving alternative to "fetch with polling", for example. Btw, in contrast to the use of the "web's native implementation",
|
Is there also a way to use streaming HTTP request? I can do it from my web-app using |
Any update? |
1 similar comment
Any update? |
Any Update? |
such a pitty that capacitor team wont reply to all these requests. |
I'm missing support of SSE in the CapacitorHttp. Could we get any updates regarding this feature, please? Thank you. |
What is the reason for even needing support in CapacitorHttp? I actually use Angular and use @angular/http (HttpClient) in all of my services - so I haven't really needed the Capacitor plugin, which only a couple years ago was still a community plugin. I have an assignment to implement SSE in my Angular app, and my plan was to write a service that directly uses the EventSource API, but then I discovered that doesn't take headers. So I did some digging, and my plan is to use the EventSourcePlus module in my service (in order to add Auth headers to it). Is there something wrong with this, or is this more of an issue for other frameworks which don't have a built-in HTTP client? (though I would have assumed that React and Vue devs are just using Axios - same question I suppose: What is the reason for not using Axios (or even fetch) in an Ionic+Capacitor app? |
I'll also out that since this issue was opened in May of 2023 (using Cap 4.7.0), Capacitor 5 came and went, and Capacitor 6 came out April 15, 2024, and Cap 6.1 came out June 11, 2024. I'd be curious if anyone has better luck with these in the latest version. Update: |
@mdledoux You are right, you can achieve the same with regular web http client libraries and the Maybe the soluition is to be actually able to configure the |
Bug Report
Capacitor Version
@capacitor/cli: 4.7.0
@capacitor/core: 4.7.0
@capacitor/ios: 4.7.0
@capacitor/android: 4.7.0
Platform(s)
iOS and Android regardless of version
Current Behavior
When using the web's
EventSource
API for use with Server-Sent Events, the CapacitorHttp plugin won't be used and instead it falls back to the web's native implementation. This is caused CORS issues when intending to use device's native HTTP handling (hence the usage of CapacitorHttp).Expected Behavior
As with
fetch
andXMLHttpRequest
,EventSource
should also be patched and work through device native events.Additional Context
Likely related to other issues similar to this since the
Content-Type
istext/event-stream
for Server-Sent events: #6299 & #6206 ?The text was updated successfully, but these errors were encountered: