mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
Parse chunked trailers when the stream API decompresses
StreamHandle::read() parsed the trailers only on the path without a decompressor, so response->trailers stayed empty for a compressed chunked response. Parse them in one place for both paths, and only after the last chunk: after a failed read it waited another read timeout for a trailer line, and parse_trailers_if_needed() called before the end read body bytes as trailers.
This commit is contained in:
1 parent
07edfb86b4
commit
2e3cb0f985
2 files changed
+19
-29
No files matched your search
@@ -23632,6 +23632,17 @@ TEST_F(OpenStreamTest, Gzip) {
|
||||
EXPECT_EQ("gzip", handle.response->get_header_value("Content-Encoding"));
|
||||
EXPECT_EQ(100u * 1024u, read_all(handle).size());
|
||||
}
|
||||
|
||||
TEST_F(OpenStreamTest, TrailersWithGzip) {
|
||||
Client cli("127.0.0.1", port_);
|
||||
auto handle =
|
||||
cli.open_stream("GET", "/streamed-chunked-with-prohibited-trailer", {},
|
||||
{{"Accept-Encoding", "gzip"}});
|
||||
ASSERT_TRUE(handle.is_valid());
|
||||
EXPECT_EQ("gzip", handle.response->get_header_value("Content-Encoding"));
|
||||
EXPECT_EQ("123456789", read_all(handle));
|
||||
EXPECT_EQ("yes", handle.response->get_trailer_value("X-Allowed"));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CPPHTTPLIB_BROTLI_SUPPORT
|
||||
|
||||
Reference in new issue
Block a user