mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Updated README
This commit is contained in:
parent
2823a94fc1
commit
bf541442ea
@ -90,14 +90,15 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
|
|||||||
const uint64_t DATA_CHUNK_SIZE = 4;
|
const uint64_t DATA_CHUNK_SIZE = 4;
|
||||||
|
|
||||||
svr.Get("/stream", [&](const Request &req, Response &res) {
|
svr.Get("/stream", [&](const Request &req, Response &res) {
|
||||||
auto data = std::make_shared<std::string>("abcdefg");
|
auto data = new std::string("abcdefg");
|
||||||
|
|
||||||
res.set_content_provider(
|
res.set_content_provider(
|
||||||
data->size(), // Content length
|
data->size(), // Content length
|
||||||
[data](uint64_t offset, uint64_t length, Out out) {
|
[data](uint64_t offset, uint64_t length, Out out) {
|
||||||
const auto &d = *data;
|
const auto &d = *data;
|
||||||
out(&d[offset], std::min(length, DATA_CHUNK_SIZE));
|
out(&d[offset], std::min(length, DATA_CHUNK_SIZE));
|
||||||
});
|
},
|
||||||
|
[data] { delete data; });
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user