libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.29k stars 903 forks source link

Handling SSE #1014

Open vymao opened 5 months ago

vymao commented 5 months ago

Is your feature request related to a problem?

Would be great if CPR could handle server sent events for streamed data. Currently I don't see mention of this in the documentation, and I'm trying to work around it by making WriteCallbacks, but this isn't optimal.

Possible Solution

A callback that instead could take in server sent events with error handling, instead of us having to parse it out manually and do a lot of string formatting with WriteCallbacks.

Alternatives

No response

Additional Context

No response

COM8 commented 5 months ago

As I understand it, a better "unbuffered" mode that invokes a callback for every event received is desired here?

vymao commented 5 months ago

Essentially yes, since right now, WriteCallbacks receive data in the form of a string, which isn't ideal to format if we are expecting JSON payloads.

COM8 commented 5 months ago

Right now this feature is not planed, but you are more than welcome to create PR for it.