1
0
mirror of synced 2025-07-27 23:41:48 +03:00

SSE client example

This commit is contained in:
yhirose
2020-07-25 11:20:57 -04:00
parent 90da199aba
commit 0e9cfd9f49
5 changed files with 42 additions and 20 deletions

View File

@ -243,7 +243,9 @@ svr.set_payload_max_length(1024 * 1024 * 512); // 512MB
### Server-Sent Events
Please check [here](https://github.com/yhirose/cpp-httplib/blob/master/example/sse.cc).
[Server example](https://github.com/yhirose/cpp-httplib/blob/master/example/ssesvr.cc)
[Client example](https://github.com/yhirose/cpp-httplib/blob/master/example/ssecli.cc)
### Default thread pool support
@ -306,20 +308,6 @@ httplib::Headers headers = {
auto res = cli.Get("/hi", headers);
```
### GET with Content Receiver
```c++
std::string body;
auto res = cli.Get("/large-data",
[&](const char *data, size_t data_length) {
body.append(data, data_length);
return true;
});
assert(res->body.empty());
```
### POST
```c++
@ -390,6 +378,16 @@ cli.set_write_timeout(5, 0); // 5 seconds
### Receive content with Content receiver
```c++
std::string body;
auto res = cli.Get("/large-data",
[&](const char *data, size_t data_length) {
body.append(data, data_length);
return true;
});
```
```cpp
std::string body;
auto res = cli.Get(