You've already forked cpp-httplib
SSE client example
This commit is contained in:
28
README.md
28
README.md
@ -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(
|
||||
|
Reference in New Issue
Block a user