Treat a zero payload limit as none when decompressing a stream

set_payload_max_length(0) means no limit, but StreamHandle compared the
decompressed size against 0, so every compressed response read through
the streaming API failed.
This commit is contained in:
yhirose committed 2026-10-16 16:39:00 -04:00
1 parent d41d5586cf
commit 194f392417
2 files changed
+13 -4

No files matched your search

+11
View File
@@ -22411,6 +22411,17 @@ TEST_F(StreamApiTest, GetWithParams) {
EXPECT_TRUE(read_body(result).find("foo=bar") != std::string::npos);
}
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
TEST_F(StreamApiTest, GetCompressedWithNoPayloadLimit) {
httplib::Client cli(HOST, PORT);
cli.set_payload_max_length(0);
auto result = httplib::stream::Get(cli, "/hello");
ASSERT_TRUE(result.is_valid());
EXPECT_FALSE(result.get_header_value("Content-Encoding").empty());
EXPECT_EQ("Hello World!", read_body(result));
}
#endif
TEST_F(StreamApiTest, GetConnectionError) {
httplib::Client cli(HOST, 9999);
EXPECT_FALSE(httplib::stream::Get(cli, "/hello").is_valid());