You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::string body;
auto res = cli.Get("/large-data",
[&](constchar *data, size_t data_length) {
body.append(data, data_length);
returntrue;
});
What I propose is to instead, allow using res as a generator, for example:
std::string body;
auto res = cli.Get("/large-data");
while (res->has_data()) {
body.append(res->data(), res->len());
res->next();
}
This will be useful for the use case where we need to pipe the response back to set_chunked_content_provider in httplib::Server (for example, doing a reverse proxy)
This will be useful for the use case where we need to pipe the response back to set_chunked_content_provider in httplib::Server (for example, doing a reverse proxy)
Otherwise, if there is a way to just give the Result returned by Client::Get() back to server's Response, I think it can also be a nice solution
@ngxson, thanks for the suggestion! It looks like it would need a lot of changes to httplib.h. I'll check how hard it is to implement when I have time.
Activity
ngxson commentedon Nov 11, 2025
Otherwise, if there is a way to just give the
Resultreturned byClient::Get()back to server'sResponse, I think it can also be a nice solutionyhirose commentedon Nov 14, 2025
@ngxson, thanks for the suggestion! It looks like it would need a lot of changes to httplib.h. I'll check how hard it is to implement when I have time.
yhirose commentedon Dec 2, 2025
@ngxson I implemented your suggestion at #2281. If you have any additional comments, please let me know. Thanks!
https://github.com/yhirose/cpp-httplib/blob/master/README.md#streaming-api
https://github.com/yhirose/cpp-httplib/blob/master/README-stream.md