mirror of
https://github.com/BlackMATov/curly.hpp.git
synced 2025-12-15 12:19:47 +07:00
rename DELETE method to DEL
This commit is contained in:
@@ -40,12 +40,12 @@ namespace curly_hpp
|
|||||||
using time_point_t = std::chrono::steady_clock::time_point;
|
using time_point_t = std::chrono::steady_clock::time_point;
|
||||||
|
|
||||||
enum class http_method {
|
enum class http_method {
|
||||||
|
DEL,
|
||||||
PUT,
|
PUT,
|
||||||
GET,
|
GET,
|
||||||
HEAD,
|
HEAD,
|
||||||
POST,
|
POST,
|
||||||
PATCH,
|
PATCH,
|
||||||
DELETE,
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -320,6 +320,12 @@ namespace curly_hpp
|
|||||||
curl_easy_setopt(curlh_.get(), CURLOPT_VERBOSE, breq_.verbose() ? 1l : 0l);
|
curl_easy_setopt(curlh_.get(), CURLOPT_VERBOSE, breq_.verbose() ? 1l : 0l);
|
||||||
|
|
||||||
switch ( breq_.method() ) {
|
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:
|
case http_method::PUT:
|
||||||
curl_easy_setopt(curlh_.get(), CURLOPT_UPLOAD, 1l);
|
curl_easy_setopt(curlh_.get(), CURLOPT_UPLOAD, 1l);
|
||||||
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
|
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
|
||||||
@@ -342,12 +348,6 @@ namespace curly_hpp
|
|||||||
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
|
curl_easy_setopt(curlh_.get(), CURLOPT_INFILESIZE_LARGE,
|
||||||
static_cast<curl_off_t>(breq_.uploader()->size()));
|
static_cast<curl_off_t>(breq_.uploader()->size()));
|
||||||
break;
|
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:
|
case http_method::OPTIONS:
|
||||||
curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
curl_easy_setopt(curlh_.get(), CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||||
curl_easy_setopt(curlh_.get(), CURLOPT_NOBODY, 1l);
|
curl_easy_setopt(curlh_.get(), CURLOPT_NOBODY, 1l);
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ TEST_CASE("curly") {
|
|||||||
|
|
||||||
auto req5 = net::request_builder()
|
auto req5 = net::request_builder()
|
||||||
.url("https://httpbin.org/put")
|
.url("https://httpbin.org/put")
|
||||||
.method(net::http_method::DELETE)
|
.method(net::http_method::DEL)
|
||||||
.send();
|
.send();
|
||||||
REQUIRE(req5.take().http_code() == 405u);
|
REQUIRE(req5.take().http_code() == 405u);
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ TEST_CASE("curly") {
|
|||||||
|
|
||||||
auto req5 = net::request_builder()
|
auto req5 = net::request_builder()
|
||||||
.url("https://httpbin.org/get")
|
.url("https://httpbin.org/get")
|
||||||
.method(net::http_method::DELETE)
|
.method(net::http_method::DEL)
|
||||||
.send();
|
.send();
|
||||||
REQUIRE(req5.take().http_code() == 405u);
|
REQUIRE(req5.take().http_code() == 405u);
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ TEST_CASE("curly") {
|
|||||||
|
|
||||||
auto req5 = net::request_builder()
|
auto req5 = net::request_builder()
|
||||||
.url("https://httpbin.org/post")
|
.url("https://httpbin.org/post")
|
||||||
.method(net::http_method::DELETE)
|
.method(net::http_method::DEL)
|
||||||
.send();
|
.send();
|
||||||
REQUIRE(req5.take().http_code() == 405u);
|
REQUIRE(req5.take().http_code() == 405u);
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ TEST_CASE("curly") {
|
|||||||
{
|
{
|
||||||
auto req = net::request_builder()
|
auto req = net::request_builder()
|
||||||
.url("https://httpbin.org/status/203")
|
.url("https://httpbin.org/status/203")
|
||||||
.method(net::http_method::DELETE)
|
.method(net::http_method::DEL)
|
||||||
.send();
|
.send();
|
||||||
REQUIRE(req.take().http_code() == 203u);
|
REQUIRE(req.take().http_code() == 203u);
|
||||||
}
|
}
|
||||||
@@ -589,7 +589,7 @@ TEST_CASE("curly") {
|
|||||||
{
|
{
|
||||||
auto resp = net::request_builder()
|
auto resp = net::request_builder()
|
||||||
.url("https://httpbin.org/anything")
|
.url("https://httpbin.org/anything")
|
||||||
.method(net::http_method::DELETE)
|
.method(net::http_method::DEL)
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.content(R"({"hello":"world"})")
|
.content(R"({"hello":"world"})")
|
||||||
.send().take();
|
.send().take();
|
||||||
|
|||||||
Reference in New Issue
Block a user