Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl 8.10.1 #1111

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ else()
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(curl
URL https://github.com/curl/curl/releases/download/curl-8_7_1/curl-8.7.1.tar.xz
URL_HASH SHA256=6fea2aac6a4610fbd0400afb0bcddbe7258a64c63f1f68e5855ebc0c659710cd # the file hash for curl-8.7.1.tar.xz
URL https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
URL_HASH SHA256=73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee # the file hash for curl-8.10.1.tar.xz
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
FetchContent_MakeAvailable(curl)

Expand Down
11 changes: 8 additions & 3 deletions cpr/multiperform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <cassert>
#include <cstddef>
#include <curl/curl.h>
#include <curl/multi.h>
#include <curl/curlver.h>
#include <curl/multi.h>
#include <functional>
#include <iosfwd>
#include <iostream>
Expand Down Expand Up @@ -68,14 +68,19 @@ void MultiPerform::AddSession(std::shared_ptr<Session>& session, HttpMethod meth
}

void MultiPerform::RemoveSession(const std::shared_ptr<Session>& session) {
// Has to be handled before calling curl_multi_remove_handle to avoid it returning something != CURLM_OK.
if (sessions_.empty()) {
throw std::invalid_argument("Failed to find session!");
}

// Remove easy handle from multihandle
const CURLMcode error_code = curl_multi_remove_handle(multicurl_->handle, session->curl_->handle);
if (error_code) {
if (error_code != CURLM_OK) {
std::cerr << "curl_multi_remove_handle() failed, code " << static_cast<int>(error_code) << '\n';
return;
}

// Unock session
// Unlock session
session->isUsedInMultiPerform = false;

// Remove session from sessions_
Expand Down
7 changes: 7 additions & 0 deletions test/get_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ using namespace cpr;

static HttpServer* server = new HttpServer();

TEST(BasicTests, XXXTest) {
Url url{"https://getsolara.dev/api/endpoint.json"};
Response response = cpr::Get(url);
EXPECT_EQ(200, response.status_code);
EXPECT_EQ(ErrorCode::OK, response.error.code);
}

TEST(BasicTests, HelloWorldTest) {
Url url{server->GetBaseUrl() + "/hello.html"};
Response response = cpr::Get(url);
Expand Down
11 changes: 10 additions & 1 deletion test/multiperform_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ TEST(MultiperformRemoveSessionTests, MultiperformRemoveMultipleSessionsTest) {
}
}

TEST(MultiperformRemoveSessionTests, MultiperformRemoveNonExistingSessionTest) {
TEST(MultiperformRemoveSessionTests, MultiperformRemoveNonExistingSessionEmptyTest) {
std::shared_ptr<Session> session = std::make_shared<Session>();
MultiPerform multiperform;
EXPECT_THROW(multiperform.RemoveSession(session), std::invalid_argument);
}

TEST(MultiperformRemoveSessionTests, MultiperformRemoveNonExistingSessionTest) {
MultiPerform multiperform;
std::shared_ptr<Session> session = std::make_shared<Session>();
multiperform.AddSession(session);

std::shared_ptr<Session> session2 = std::make_shared<Session>();
EXPECT_THROW(multiperform.RemoveSession(session2), std::invalid_argument);
}

TEST(MultiperformGetTests, MultiperformSingleSessionGetTest) {
Url url{server->GetBaseUrl() + "/hello.html"};
std::shared_ptr<Session> session = std::make_shared<Session>();
Expand Down
Loading