diff --git a/headers/curly.hpp/curly.hpp b/headers/curly.hpp/curly.hpp index acdd3f3..68a1cc6 100644 --- a/headers/curly.hpp/curly.hpp +++ b/headers/curly.hpp/curly.hpp @@ -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 }; diff --git a/sources/curly.hpp/curly.cpp b/sources/curly.hpp/curly.cpp index 389fcf3..6b268cf 100644 --- a/sources/curly.hpp/curly.cpp +++ b/sources/curly.hpp/curly.cpp @@ -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(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(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(breq_.uploader()->size())); - break; case http_method::OPTIONS: curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "OPTIONS"); curl_easy_setopt(curlh_.get(), CURLOPT_NOBODY, 1l); diff --git a/untests/curly_tests.cpp b/untests/curly_tests.cpp index e90c5cd..5905d13 100644 --- a/untests/curly_tests.cpp +++ b/untests/curly_tests.cpp @@ -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();