Add PUT method to http client
This commit is contained in:
1 parent
1c7965b590
commit
baae080402
3 files changed
+24
-1
No files matched your search
@@ -80,6 +80,19 @@ void HttpClient::post(
|
||||
perform(curl_req, response);
|
||||
}
|
||||
|
||||
void HttpClient::put(
|
||||
const string &url,
|
||||
const string &body,
|
||||
const unordered_map<string, string> &headers,
|
||||
IHttpResponse *response) {
|
||||
_LOG_REQ_BEGIN(PUT, url, headers);
|
||||
curlpp::Easy curl_req;
|
||||
init_request_common(curl_req, url, headers);
|
||||
curl_req.setOpt<curlpp::options::Put>(true);
|
||||
curl_req.setOpt<curlpp::options::PostFields>(body);
|
||||
perform(curl_req, response);
|
||||
}
|
||||
|
||||
void HttpClient::get(
|
||||
const string &url,
|
||||
const unordered_map<string, string> &headers,
|
||||
|
||||
@@ -47,6 +47,15 @@ class HttpClient {
|
||||
const std::unordered_map<std::string, std::string> &headers,
|
||||
IHttpResponse *response);
|
||||
|
||||
/**
|
||||
* Performs an http PUT request
|
||||
*/
|
||||
static void put(
|
||||
const std::string &url,
|
||||
const std::string &body,
|
||||
const std::unordered_map<std::string, std::string> &headers,
|
||||
IHttpResponse *response);
|
||||
|
||||
/**
|
||||
* Requests an oauth access token
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user