Skip to content

Commit

Permalink
fix: curl return code could be 7 when there is DNS error redirection …
Browse files Browse the repository at this point in the history
…for bad hosts (issue libcpr#1165)
  • Loading branch information
Jerry-Terrasse committed Jan 25, 2025
1 parent 0e6bf15 commit 35eedb8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/error_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TEST(ErrorTests, ProxyFailure) {
Response response = cpr::Get(url, cpr::Proxies{{"http", "http://bad_host.libcpr.org"}});
EXPECT_EQ(url, response.url);
EXPECT_EQ(0, response.status_code);
EXPECT_EQ(ErrorCode::COULDNT_RESOLVE_PROXY, response.error.code);
EXPECT_TRUE(response.error.code == ErrorCode::COULDNT_RESOLVE_PROXY || response.error.code == ErrorCode::COULDNT_CONNECT);
}

TEST(ErrorTests, BoolFalseTest) {
Expand Down
3 changes: 2 additions & 1 deletion test/get_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <chrono>
#include <cpr/error.h>
#include <gtest/gtest.h>

#include <memory>
Expand Down Expand Up @@ -112,7 +113,7 @@ TEST(BasicTests, BadHostTest) {
EXPECT_EQ(std::string{}, response.text);
EXPECT_EQ(url, response.url);
EXPECT_EQ(0, response.status_code);
EXPECT_EQ(ErrorCode::COULDNT_RESOLVE_HOST, response.error.code);
EXPECT_TRUE(response.error.code == ErrorCode::COULDNT_RESOLVE_HOST || response.error.code == ErrorCode::COULDNT_CONNECT);
}

TEST(CookiesTests, BasicCookiesTest) {
Expand Down
2 changes: 1 addition & 1 deletion test/head_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(HeadTests, BadHostHeadTest) {
EXPECT_EQ(std::string{}, response.text);
EXPECT_EQ(url, response.url);
EXPECT_EQ(0, response.status_code);
EXPECT_EQ(ErrorCode::COULDNT_RESOLVE_HOST, response.error.code);
EXPECT_TRUE(response.error.code == ErrorCode::COULDNT_RESOLVE_HOST || response.error.code == ErrorCode::COULDNT_CONNECT);
}

TEST(HeadTests, CookieHeadTest) {
Expand Down
2 changes: 1 addition & 1 deletion test/post_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TEST(UrlEncodedPostTests, UrlPostBadHostTest) {
EXPECT_EQ(url, response.url);
EXPECT_EQ(std::string{}, response.header["content-type"]);
EXPECT_EQ(0, response.status_code);
EXPECT_EQ(ErrorCode::COULDNT_RESOLVE_HOST, response.error.code);
EXPECT_TRUE(response.error.code == ErrorCode::COULDNT_RESOLVE_HOST || response.error.code == ErrorCode::COULDNT_CONNECT);
}

TEST(UrlEncodedPostTests, FormPostSingleTest) {
Expand Down
2 changes: 1 addition & 1 deletion test/raw_body_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ TEST(BodyPostTests, UrlPostBadHostTest) {
EXPECT_EQ(url, response.url);
EXPECT_EQ(std::string{}, response.header["content-type"]);
EXPECT_EQ(0, response.status_code);
EXPECT_EQ(ErrorCode::COULDNT_RESOLVE_HOST, response.error.code);
EXPECT_TRUE(response.error.code == ErrorCode::COULDNT_RESOLVE_HOST || response.error.code == ErrorCode::COULDNT_CONNECT);
}

TEST(BodyPostTests, StringMoveBodyTest) {
Expand Down

0 comments on commit 35eedb8

Please sign in to comment.