any possible way to get the request stream?
Hu1-Li opened this issue · 1 comments
Hu1-Li commented
i tried this:
#include "httplib.h"
#include <array>
#include <asio.hpp>
#include <iostream>
#include <regex>
int main()
{
asio::io_context io_context;
httplib::Client client("httpbin.org");
httplib::Headers headers = {{"Content-Type", "application/json"}};
httplib::Request req;
req.path = "/post";
req.method = "POST";
req.headers = headers;
auto body = R"({"x": 1, "y": 2})";
req.body = body;
httplib::detail::BufferStream bstrm;
auto error = httplib::Error::Success;
bool s = client.cli_->write_request(bstrm, req, true, error);
return 0;
}
but the cli_
and write_request
are private method, i need to tweak the source code, is there any other possible way to get the request stream? then i can perform asio send.
yhirose commented
A simple answer is no. The stream object is managed only by cpp-httplib and hidden from users.
If you want to do 'streaming', please use a content provider.
https://github.com/yhirose/cpp-httplib?tab=readme-ov-file#send-content-with-a-content-provider