1
0
mirror of synced 2025-12-18 16:34:09 +03:00

Implement SSEClient

This commit is contained in:
yhirose
2025-12-14 19:10:34 -05:00
parent 7eb03e81fc
commit b35c468cca
6 changed files with 1621 additions and 382 deletions

View File

@@ -1206,8 +1206,8 @@ std::string decoded_component = httplib::decode_uri_component(encoded_component)
Use `encode_uri()` for full URLs and `encode_uri_component()` for individual query parameters or path segments.
Streaming API
-------------
Stream API
----------
Process large responses without loading everything into memory.
@@ -1234,6 +1234,28 @@ All HTTP methods are supported: `stream::Get`, `Post`, `Put`, `Patch`, `Delete`,
See [README-stream.md](README-stream.md) for more details.
SSE Client
----------
```cpp
#include <httplib.h>
int main() {
httplib::Client cli("http://localhost:8080");
httplib::sse::SSEClient sse(cli, "/events");
sse.on_message([](const httplib::sse::SSEMessage &msg) {
std::cout << "Event: " << msg.event << std::endl;
std::cout << "Data: " << msg.data << std::endl;
});
sse.start(); // Blocking, with auto-reconnect
return 0;
}
```
See [README-sse.md](README-sse.md) for more details.
Split httplib.h into .h and .cc
-------------------------------