diff --git a/src/lib_http/http/http_client.cpp b/src/lib_http/http/http_client.cpp index 88991a396..da415660d 100644 --- a/src/lib_http/http/http_client.cpp +++ b/src/lib_http/http/http_client.cpp @@ -80,6 +80,19 @@ void HttpClient::post( perform(curl_req, response); } +void HttpClient::put( + const string &url, + const string &body, + const unordered_map &headers, + IHttpResponse *response) { + _LOG_REQ_BEGIN(PUT, url, headers); + curlpp::Easy curl_req; + init_request_common(curl_req, url, headers); + curl_req.setOpt(true); + curl_req.setOpt(body); + perform(curl_req, response); +} + void HttpClient::get( const string &url, const unordered_map &headers, diff --git a/src/lib_http/http/http_client.h b/src/lib_http/http/http_client.h index 0dd283bb9..43cf0fda7 100644 --- a/src/lib_http/http/http_client.h +++ b/src/lib_http/http/http_client.h @@ -47,6 +47,15 @@ class HttpClient { const std::unordered_map &headers, IHttpResponse *response); + /** + * Performs an http PUT request + */ + static void put( + const std::string &url, + const std::string &body, + const std::unordered_map &headers, + IHttpResponse *response); + /** * Requests an oauth access token * diff --git a/src/lib_http/http/http_method.h b/src/lib_http/http/http_method.h index 9e396ffa0..4c4287823 100644 --- a/src/lib_http/http/http_method.h +++ b/src/lib_http/http/http_method.h @@ -13,7 +13,8 @@ namespace bts::http { #define FOR_ALL_VALUES(per_value) \ per_value(HttpMethod, NONE) \ per_value(HttpMethod, GET) \ - per_value(HttpMethod, POST) + per_value(HttpMethod, POST) \ + per_value(HttpMethod, PUT) // clang-format on /**