35 std::vector<std::string> headers;
38 static Curl get(
const std::string& address,
int port,
const std::string& endpoint) {
43 c.endpoint = endpoint;
47 static Curl post(
const std::string& address,
int port,
const std::string& endpoint,
48 const std::string& data,
const std::string& mime_type) {
53 c.endpoint = endpoint;
55 c.headers.push_back(std::string(
"Content-Type: ") + mime_type);
59 std::string to_string()
const {
62 buf +=
" -X " + method;
63 for (
const auto& h : headers) {
64 buf +=
" -H '" + h +
"'";
67 buf +=
" -d '" + data +
"'";
69 buf +=
" http://" + address +
":" + std::to_string(port);
70 if (endpoint !=
"" && endpoint[0] !=
'/') {