You've already forked cpp-httplib
Updated README
This commit is contained in:
37
README.md
37
README.md
@ -128,25 +128,6 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
|
|||||||
// file.content_type;
|
// file.content_type;
|
||||||
// file.content;
|
// file.content;
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Send content with Content provider
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
const uint64_t DATA_CHUNK_SIZE = 4;
|
|
||||||
|
|
||||||
svr.Get("/stream", [&](const Request &req, Response &res) {
|
|
||||||
auto data = new std::string("abcdefg");
|
|
||||||
|
|
||||||
res.set_content_provider(
|
|
||||||
data->size(), // Content length
|
|
||||||
[data](uint64_t offset, uint64_t length, DataSink &sink) {
|
|
||||||
const auto &d = *data;
|
|
||||||
sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE));
|
|
||||||
},
|
|
||||||
[data] { delete data; });
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Receive content with Content receiver
|
### Receive content with Content receiver
|
||||||
@ -176,6 +157,24 @@ svr.Post("/content_receiver",
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Send content with Content provider
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
const uint64_t DATA_CHUNK_SIZE = 4;
|
||||||
|
|
||||||
|
svr.Get("/stream", [&](const Request &req, Response &res) {
|
||||||
|
auto data = new std::string("abcdefg");
|
||||||
|
|
||||||
|
res.set_content_provider(
|
||||||
|
data->size(), // Content length
|
||||||
|
[data](uint64_t offset, uint64_t length, DataSink &sink) {
|
||||||
|
const auto &d = *data;
|
||||||
|
sink.write(&d[offset], std::min(length, DATA_CHUNK_SIZE));
|
||||||
|
},
|
||||||
|
[data] { delete data; });
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Chunked transfer encoding
|
### Chunked transfer encoding
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
Reference in New Issue
Block a user