gentoo/dev-cpp/cpp-httplib/files/0.27.0-fixpidtest.patch
Alexey Sokolov 7199a23208
dev-cpp/cpp-httplib: add 0.27.0
Signed-off-by: Alexey Sokolov <alexey+gentoo@asokolov.org>
Part-of: https://github.com/gentoo/gentoo/pull/44362
Closes: https://github.com/gentoo/gentoo/pull/44362
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
2025-11-02 16:16:17 -05:00

110 lines
3.9 KiB
Diff

From 551f96d4a2a07a56d72a13d4837b31eead884d34 Mon Sep 17 00:00:00 2001
From: yhirose <yuji.hirose.bug@gmail.com>
Date: Mon, 27 Oct 2025 20:40:12 -0400
Subject: [PATCH] Remove REMOTE_PORT dependency from UnixSocketTest.PeerPid
---
.gitignore | 2 ++
test/test.cc | 26 +++++++++++++-------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index b9acdca78e..21839782df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,8 @@ example/one_time_request
!example/one_time_request.*
example/server_and_client
!example/server_and_client.*
+example/accept_header
+!example/accept_header.*
example/*.pem
test/httplib.cc
test/httplib.h
diff --git a/test/test.cc b/test/test.cc
index e5b3639629..c9d6421719 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -196,7 +196,7 @@ TEST_F(UnixSocketTest, PeerPid) {
std::string remote_port_val;
svr.Get(pattern_, [&](const httplib::Request &req, httplib::Response &res) {
res.set_content(content_, "text/plain");
- remote_port_val = req.get_header_value("REMOTE_PORT");
+ remote_port_val = std::to_string(req.remote_port);
});
std::thread t{[&] {
@@ -11236,7 +11236,8 @@ TEST(ForwardedHeadersTest, NoProxiesSetting) {
EXPECT_EQ(StatusCode::OK_200, res->status);
EXPECT_EQ(observed_xff, "203.0.113.66");
- EXPECT_TRUE(observed_remote_addr == "::1" || observed_remote_addr == "127.0.0.1");
+ EXPECT_TRUE(observed_remote_addr == "::1" ||
+ observed_remote_addr == "127.0.0.1");
}
TEST(ForwardedHeadersTest, NoForwardedHeaders) {
@@ -11269,7 +11270,8 @@ TEST(ForwardedHeadersTest, NoForwardedHeaders) {
EXPECT_EQ(StatusCode::OK_200, res->status);
EXPECT_EQ(observed_xff, "");
- EXPECT_TRUE(observed_remote_addr == "::1" || observed_remote_addr == "127.0.0.1");
+ EXPECT_TRUE(observed_remote_addr == "::1" ||
+ observed_remote_addr == "127.0.0.1");
}
TEST(ForwardedHeadersTest, SingleTrustedProxy_UsesIPBeforeTrusted) {
@@ -11296,7 +11298,8 @@ TEST(ForwardedHeadersTest, SingleTrustedProxy_UsesIPBeforeTrusted) {
svr.wait_until_ready();
Client cli(HOST, PORT);
- auto res = cli.Get("/ip", {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66"}});
+ auto res =
+ cli.Get("/ip", {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66"}});
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
@@ -11330,8 +11333,7 @@ TEST(ForwardedHeadersTest, MultipleTrustedProxies_UsesClientIP) {
Client cli(HOST, PORT);
auto res = cli.Get(
- "/ip",
- {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66, 192.0.2.45"}});
+ "/ip", {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66, 192.0.2.45"}});
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
@@ -11364,8 +11366,8 @@ TEST(ForwardedHeadersTest, TrustedProxyNotInHeader_UsesFirstFromXFF) {
svr.wait_until_ready();
Client cli(HOST, PORT);
- auto res = cli.Get("/ip",
- {{"X-Forwarded-For", "198.51.100.23, 198.51.100.24"}});
+ auto res =
+ cli.Get("/ip", {{"X-Forwarded-For", "198.51.100.23, 198.51.100.24"}});
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
@@ -11399,8 +11401,7 @@ TEST(ForwardedHeadersTest, LastHopTrusted_SelectsImmediateLeftIP) {
Client cli(HOST, PORT);
auto res = cli.Get(
- "/ip",
- {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66, 192.0.2.45"}});
+ "/ip", {{"X-Forwarded-For", "198.51.100.23, 203.0.113.66, 192.0.2.45"}});
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
@@ -11433,9 +11434,8 @@ TEST(ForwardedHeadersTest, HandlesWhitespaceAroundIPs) {
svr.wait_until_ready();
Client cli(HOST, PORT);
- auto res = cli.Get(
- "/ip",
- {{"X-Forwarded-For", " 198.51.100.23 , 203.0.113.66 , 192.0.2.45 "}});
+ auto res = cli.Get("/ip", {{"X-Forwarded-For",
+ " 198.51.100.23 , 203.0.113.66 , 192.0.2.45 "}});
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);