@@ -56,6 +56,16 @@ class StreamingServerTest : public ::testing::Test {
5656 res.set_content (" Hello World!" , " text/plain" );
5757 });
5858
59+ server_.Get (" /echo-params" ,
60+ [](const httplib::Request &req, httplib::Response &res) {
61+ std::string result;
62+ for (const auto &p : req.params ) {
63+ if (!result.empty ()) result += " &" ;
64+ result += p.first + " =" + p.second ;
65+ }
66+ res.set_content (result, " text/plain" );
67+ });
68+
5969 server_.Get (
6070 " /chunked" , [](const httplib::Request &, httplib::Response &res) {
6171 res.set_chunked_content_provider (
@@ -280,6 +290,34 @@ TEST_F(StreamingServerTest, stream_Get_404) {
280290 EXPECT_EQ (404 , result.status ());
281291}
282292
293+ TEST_F (StreamingServerTest, stream_Get_WithParams) {
294+ httplib::Client cli (" localhost" , 8787 );
295+ httplib::Params params = {{" foo" , " bar" }, {" baz" , " 123" }};
296+
297+ auto result = httplib::stream::Get (cli, " /echo-params" , params);
298+
299+ ASSERT_TRUE (result.is_valid ());
300+ EXPECT_EQ (200 , result.status ());
301+
302+ std::string body = result.read_all ();
303+ EXPECT_TRUE (body.find (" foo=bar" ) != std::string::npos);
304+ EXPECT_TRUE (body.find (" baz=123" ) != std::string::npos);
305+ }
306+
307+ TEST_F (StreamingServerTest, stream_Get_WithParamsAndHeaders) {
308+ httplib::Client cli (" localhost" , 8787 );
309+ httplib::Params params = {{" key" , " value" }};
310+ httplib::Headers headers = {{" X-Custom-Header" , " test" }};
311+
312+ auto result = httplib::stream::Get (cli, " /echo-params" , params, headers);
313+
314+ ASSERT_TRUE (result.is_valid ());
315+ EXPECT_EQ (200 , result.status ());
316+
317+ std::string body = result.read_all ();
318+ EXPECT_TRUE (body.find (" key=value" ) != std::string::npos);
319+ }
320+
283321TEST (GeneratorTest, EmptyGenerator) {
284322 auto gen = []() -> httplib::Generator<int > { co_return ; }();
285323
0 commit comments