C
C#12mo ago
Vortac

✅ Streaming From REST API?

I'm building an SDK to interface with a REST API, and for one of then endpoints you can supply a boolean to specify if you want streaming or not. In particular, it mentions:
// Default: false
// Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
// Default: false
// Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
I'm just wondering, do I use HTTPClient for this? Or is there another way to handle streams?
5 Replies
Angius
Angius12mo ago
client.GetStreamAsync() perhaps?
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Vortac
VortacOP12mo ago
Say this is for a chat and I want to pass a ChatRequest object, would I open the stream first and then pass it?
Angius
Angius12mo ago
If it's for a chat, you should be using a real-time protocol Far as what to do with that request...? Well, it is a stream. So sure, you can read it to the end and forward it
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server