From cb7019a0fdc1ee861a5a2ab65d49845d7b194bb8 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 10 Jan 2020 14:33:33 +0100 Subject: [PATCH] Allow HTTP POST without parameters. --- src/curl_wrapper.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index d7e152f..b4ba74e 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -101,10 +101,17 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri, } case http_method::POST: { - curl_mime *mime{parameters_to_curl_mime(uri, parameters)}; - - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) - code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime); + if (parameters.empty()) + { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + code = curl_easy_setopt(_connection, CURLOPT_POST, 1L); + } + else + { + curl_mime *mime{parameters_to_curl_mime(uri, parameters)}; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime); + } break; }