summaryrefslogtreecommitdiffstats
path: root/src/curl_wrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/curl_wrapper.cpp')
-rw-r--r--src/curl_wrapper.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp
index f613766..d224ef5 100644
--- a/src/curl_wrapper.cpp
+++ b/src/curl_wrapper.cpp
@@ -86,10 +86,9 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
{
case http_method::GET:
{
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- code = curl_easy_setopt(_connection, CURLOPT_HTTPGET, 1L);
-
add_parameters_to_uri(uri, parameters);
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
+ curl_easy_setopt(_connection, CURLOPT_HTTPGET, 1L);
break;
}
@@ -98,13 +97,13 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
if (parameters.empty())
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- code = curl_easy_setopt(_connection, CURLOPT_POST, 1L);
+ 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);
+ curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
}
break;
@@ -115,11 +114,15 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
{
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+ curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
}
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, "PATCH");
+ if (code != CURLE_OK)
+ {
+ throw CURLException{code, "Failed to set URI", _curl_buffer_error};
+ }
break;
}
@@ -129,11 +132,15 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
{
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+ curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
}
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, "PUT");
+ if (code != CURLE_OK)
+ {
+ throw CURLException{code, "Failed to set URI", _curl_buffer_error};
+ }
break;
}
@@ -143,20 +150,19 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
{
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+ curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
}
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, "DELETE");
+ if (code != CURLE_OK)
+ {
+ throw CURLException{code, "Failed to set URI", _curl_buffer_error};
+ }
break;
}
}
- if (code != CURLE_OK)
- {
- throw CURLException{code, "Failed to set HTTP method",
- _curl_buffer_error};
- }
debuglog << "Making request to: " << uri << '\n';
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)