Skip to content
Snippets Groups Projects
Verified Commit 417821a0 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Can't close handle in continuation anymore

parent fc7af830
No related branches found
No related tags found
No related merge requests found
Pipeline #1281 passed
......@@ -29,8 +29,6 @@ int main(int, char **) {
r->request("ABCD");
r->on_complete([](const coeurl::Request &) {});
g.submit_request(r);
g.close();
});
t.join();
......
......@@ -14,12 +14,11 @@ using namespace coeurl;
TEST_CASE("Basic request") {
Client g{};
g.get("http://localhost:5000/", [&g](const Request &r) {
g.get("http://localhost:5000/", [](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
g.close();
});
}
......@@ -28,12 +27,11 @@ TEST_CASE("Basic manual request") {
auto r = std::make_shared<Request>(&g, Request::Method::GET,
"http://localhost:5000/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
g.close();
});
g.submit_request(r);
......@@ -44,11 +42,10 @@ TEST_CASE("Basic redirect") {
g.get(
"http://localhost:5000/redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "http://localhost:5000/redirect");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
g.close();
},
{}, 1);
}
......@@ -58,10 +55,9 @@ TEST_CASE("No redirect") {
g.get(
"http://localhost:5000/redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "http://localhost:5000/redirect");
CHECK(r.response_code() == 302);
g.close();
},
{}, 0);
}
......@@ -71,10 +67,9 @@ TEST_CASE("Max redirects") {
g.get(
"http://localhost:5000/double_redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "http://localhost:5000/double_redirect");
CHECK(r.response_code() == 302);
g.close();
},
{}, 1);
}
......@@ -85,11 +80,10 @@ TEST_CASE("Basic manual POST request") {
auto r = std::make_shared<Request>(&g, Request::Method::POST,
"http://localhost:5000/post");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
g.submit_request(r);
......@@ -101,11 +95,10 @@ TEST_CASE("Basic manual PUT request") {
auto r = std::make_shared<Request>(&g, Request::Method::PUT,
"http://localhost:5000/put");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
g.submit_request(r);
......@@ -116,11 +109,10 @@ TEST_CASE("Basic manual HEAD request") {
auto r = std::make_shared<Request>(&g, Request::Method::HEAD,
"http://localhost:5000/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
});
g.submit_request(r);
......@@ -131,14 +123,12 @@ TEST_CASE("Basic manual OPTIONS request") {
auto r = std::make_shared<Request>(&g, Request::Method::OPTIONS,
"http://localhost:5000/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
CHECK(r.response_headers()["allow"].find("GET") != std::string::npos);
g.close();
});
g.submit_request(r);
......@@ -149,11 +139,9 @@ TEST_CASE("Basic manual DELETE request") {
auto r = std::make_shared<Request>(&g, Request::Method::DELETE,
"http://localhost:5000/delete");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "http://localhost:5000/delete");
CHECK(r.response_code() == 200);
g.close();
});
g.submit_request(r);
......@@ -163,11 +151,10 @@ TEST_CASE("Basic simple POST request") {
Client g{};
g.post("http://localhost:5000/post", "ABCD", "text/plain",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "http://localhost:5000/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
}
......@@ -175,46 +162,40 @@ TEST_CASE("Basic simple PUT request") {
Client g{};
g.put("http://localhost:5000/put", "ABCD", "text/plain",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "http://localhost:5000/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
}
TEST_CASE("Basic simple HEAD request") {
Client g{};
g.head("http://localhost:5000/", [&g](const Request &r) {
g.head("http://localhost:5000/", [](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
});
}
TEST_CASE("Basic simple OPTIONS request") {
Client g{};
g.options("http://localhost:5000/", [&g](const Request &r) {
g.options("http://localhost:5000/", [](const Request &r) {
CHECK(r.url() == "http://localhost:5000/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
CHECK(r.response_headers()["allow"].find("GET") != std::string::npos);
g.close();
});
}
TEST_CASE("Basic simple DELETE request") {
Client g{};
g.delete_("http://localhost:5000/delete", [&g](const Request &r) {
g.delete_("http://localhost:5000/delete", [](const Request &r) {
CHECK(r.url() == "http://localhost:5000/delete");
CHECK(r.response_code() == 200);
g.close();
});
}
......@@ -16,13 +16,12 @@ TEST_CASE("Basic request") {
Client g{};
g.set_verify_peer(false);
g.get("https://localhost:5443/", [&g](const Request &r) {
g.get("https://localhost:5443/", [](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.error_code() == CURLE_OK);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
g.close();
});
}
......@@ -32,12 +31,11 @@ TEST_CASE("Basic manual request") {
auto r = std::make_shared<Request>(&g, Request::Method::GET,
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
g.close();
});
g.submit_request(r);
......@@ -49,11 +47,10 @@ TEST_CASE("Basic redirect") {
g.get(
"https://localhost:5443/redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "https://localhost:5443/redirect");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
g.close();
},
{}, 1);
}
......@@ -64,10 +61,9 @@ TEST_CASE("No redirect") {
g.get(
"https://localhost:5443/redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "https://localhost:5443/redirect");
CHECK(r.response_code() == 302);
g.close();
},
{}, 0);
}
......@@ -78,10 +74,9 @@ TEST_CASE("Max redirects") {
g.get(
"https://localhost:5443/double_redirect",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "https://localhost:5443/double_redirect");
CHECK(r.response_code() == 302);
g.close();
},
{}, 1);
}
......@@ -93,11 +88,10 @@ TEST_CASE("Basic manual POST request") {
auto r = std::make_shared<Request>(&g, Request::Method::POST,
"https://localhost:5443/post");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
g.submit_request(r);
......@@ -110,11 +104,10 @@ TEST_CASE("Basic manual PUT request") {
auto r = std::make_shared<Request>(&g, Request::Method::PUT,
"https://localhost:5443/put");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
g.submit_request(r);
......@@ -126,11 +119,10 @@ TEST_CASE("Basic manual HEAD request") {
auto r = std::make_shared<Request>(&g, Request::Method::HEAD,
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
});
g.submit_request(r);
......@@ -142,14 +134,12 @@ TEST_CASE("Basic manual OPTIONS request") {
auto r = std::make_shared<Request>(&g, Request::Method::OPTIONS,
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
CHECK(r.response_headers()["allow"].find("GET") != std::string::npos);
g.close();
});
g.submit_request(r);
......@@ -161,11 +151,9 @@ TEST_CASE("Basic manual DELETE request") {
auto r = std::make_shared<Request>(&g, Request::Method::DELETE,
"https://localhost:5443/delete");
r->on_complete([&g](const Request &r) {
r->on_complete([](const Request &r) {
CHECK(r.url() == "https://localhost:5443/delete");
CHECK(r.response_code() == 200);
g.close();
});
g.submit_request(r);
......@@ -176,11 +164,10 @@ TEST_CASE("Basic simple POST request") {
g.set_verify_peer(false);
g.post("https://localhost:5443/post", "ABCD", "text/plain",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "https://localhost:5443/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
}
......@@ -189,11 +176,10 @@ TEST_CASE("Basic simple PUT request") {
g.set_verify_peer(false);
g.put("https://localhost:5443/put", "ABCD", "text/plain",
[&g](const Request &r) {
[](const Request &r) {
CHECK(r.url() == "https://localhost:5443/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
});
}
......@@ -201,11 +187,10 @@ TEST_CASE("Basic simple HEAD request") {
Client g{};
g.set_verify_peer(false);
g.head("https://localhost:5443/", [&g](const Request &r) {
g.head("https://localhost:5443/", [](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
});
}
......@@ -213,14 +198,12 @@ TEST_CASE("Basic simple OPTIONS request") {
Client g{};
g.set_verify_peer(false);
g.options("https://localhost:5443/", [&g](const Request &r) {
g.options("https://localhost:5443/", [](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
CHECK(r.response_headers()["allow"].find("GET") != std::string::npos);
g.close();
});
}
......@@ -228,10 +211,8 @@ TEST_CASE("Basic simple DELETE request") {
Client g{};
g.set_verify_peer(false);
g.delete_("https://localhost:5443/delete", [&g](const Request &r) {
g.delete_("https://localhost:5443/delete", [](const Request &r) {
CHECK(r.url() == "https://localhost:5443/delete");
CHECK(r.response_code() == 200);
g.close();
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment