rename DELETE method to DEL

This commit is contained in:
2019-07-07 15:15:34 +07:00
parent 8f1dad571f
commit fb124a2208
3 changed files with 12 additions and 12 deletions

View File

@@ -40,12 +40,12 @@ namespace curly_hpp
using time_point_t = std::chrono::steady_clock::time_point;
enum class http_method {
DEL,
PUT,
GET,
HEAD,
POST,
PATCH,
DELETE,
OPTIONS
};

View File

@@ -320,6 +320,12 @@ namespace curly_hpp
curl_easy_setopt(curlh_.get(), CURLOPT_VERBOSE, breq_.verbose() ? 1l : 0l);
switch ( breq_.method() ) {
case http_method::DEL:
curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(curlh_.get(), CURLOPT_POST, 1l);
curl_easy_setopt(curlh_.get(), CURLOPT_POSTFIELDSIZE_LARGE,
static_cast<curl_off_t>(breq_.uploader()->size()));
break;
case http_method::PUT:
curl_easy_setopt(curlh_.get(), CURLOPT_UPLOAD, 1l);
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
@@ -342,12 +348,6 @@ namespace curly_hpp
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
static_cast<curl_off_t>(breq_.uploader()->size()));
break;
case http_method::DELETE:
curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(curlh_.get(), CURLOPT_POST, 1l);
curl_easy_setopt(curlh_.get(), CURLOPT_POSTFIELDSIZE_LARGE,
static_cast<curl_off_t>(breq_.uploader()->size()));
break;
case http_method::OPTIONS:
curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "OPTIONS");
curl_easy_setopt(curlh_.get(), CURLOPT_NOBODY, 1l);

View File

@@ -230,7 +230,7 @@ TEST_CASE("curly") {
auto req5 = net::request_builder()
.url("https://httpbin.org/put")
.method(net::http_method::DELETE)
.method(net::http_method::DEL)
.send();
REQUIRE(req5.take().http_code() == 405u);
}
@@ -267,7 +267,7 @@ TEST_CASE("curly") {
auto req5 = net::request_builder()
.url("https://httpbin.org/get")
.method(net::http_method::DELETE)
.method(net::http_method::DEL)
.send();
REQUIRE(req5.take().http_code() == 405u);
}
@@ -304,7 +304,7 @@ TEST_CASE("curly") {
auto req5 = net::request_builder()
.url("https://httpbin.org/post")
.method(net::http_method::DELETE)
.method(net::http_method::DEL)
.send();
REQUIRE(req5.take().http_code() == 405u);
}
@@ -364,7 +364,7 @@ TEST_CASE("curly") {
{
auto req = net::request_builder()
.url("https://httpbin.org/status/203")
.method(net::http_method::DELETE)
.method(net::http_method::DEL)
.send();
REQUIRE(req.take().http_code() == 203u);
}
@@ -589,7 +589,7 @@ TEST_CASE("curly") {
{
auto resp = net::request_builder()
.url("https://httpbin.org/anything")
.method(net::http_method::DELETE)
.method(net::http_method::DEL)
.header("Content-Type", "application/json")
.content(R"({"hello":"world"})")
.send().take();