Keep a Client usable when its URL cannot be used

An unsupported scheme without exceptions, or a port out of range, left
Client with no implementation, so the first request after it went
through a null pointer. Put a client in its place that reports itself
invalid and fails every request with Error::Connection.
This commit is contained in:
yhirose committed 2026-10-16 16:39:00 -04:00
1 parent 0116be0a2b
commit b270564c18
2 files changed
+27 -1

No files matched your search

+4
View File
@@ -14627,6 +14627,10 @@ TEST(HostAndPortPropertiesTest, PortOutOfRange) {
// Port 99999 exceeds valid range (1-65535) — should not crash
httplib::Client cli("http://www.google.com:99999");
ASSERT_FALSE(cli.is_valid());
auto res = cli.Get("/");
EXPECT_FALSE(res);
EXPECT_EQ(Error::Connection, res.error());
}
TEST(HostAndPortPropertiesTest, TrailingCharactersInPort) {