From b845425cd0ab18ce1b49284c8dab642a82fcf1b5 Mon Sep 17 00:00:00 2001
From: yhirose <yuji.hirose.bug@gmail.com>
Date: Tue, 16 Mar 2021 19:40:15 -0400
Subject: [PATCH] Fix #878

---
 httplib.h    |  2 +-
 test/test.cc | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/httplib.h b/httplib.h
index 1f54a1d..87f58e4 100644
--- a/httplib.h
+++ b/httplib.h
@@ -5933,7 +5933,7 @@ inline Result ClientImpl::Get(const char *path, const Params &params,
   }
 
   std::string path_with_query = detail::append_query_params(path, params);
-  return Get(path_with_query.c_str(), params, headers, response_handler,
+  return Get(path_with_query.c_str(), headers, response_handler,
              content_receiver, progress);
 }
 
diff --git a/test/test.cc b/test/test.cc
index fe35d75..58f3c48 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -3495,6 +3495,69 @@ TEST(ErrorHandlerWithContentProviderTest, ErrorHandler) {
   ASSERT_FALSE(svr.is_running());
 }
 
+TEST(GetWithParametersTest, GetWithParameters) {
+  Server svr;
+
+  svr.Get("/", [&](const Request & req, Response &res) {
+    auto text = req.get_param_value("hello");
+    res.set_content(text, "text/plain");
+  });
+
+  auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); });
+  while (!svr.is_running()) {
+    std::this_thread::sleep_for(std::chrono::milliseconds(1));
+  }
+  std::this_thread::sleep_for(std::chrono::seconds(1));
+
+  Client cli("localhost", PORT);
+
+  Params params;
+  params.emplace("hello", "world");
+  auto res = cli.Get("/", params, Headers{});
+
+  ASSERT_TRUE(res);
+  EXPECT_EQ(200, res->status);
+  EXPECT_EQ("world", res->body);
+
+  svr.stop();
+  listen_thread.join();
+  ASSERT_FALSE(svr.is_running());
+}
+
+TEST(GetWithParametersTest, GetWithParameters2) {
+  Server svr;
+
+  svr.Get("/", [&](const Request & req, Response &res) {
+    auto text = req.get_param_value("hello");
+    res.set_content(text, "text/plain");
+  });
+
+  auto listen_thread = std::thread([&svr]() { svr.listen("localhost", PORT); });
+  while (!svr.is_running()) {
+    std::this_thread::sleep_for(std::chrono::milliseconds(1));
+  }
+  std::this_thread::sleep_for(std::chrono::seconds(1));
+
+  Client cli("localhost", PORT);
+
+  Params params;
+  params.emplace("hello", "world");
+
+  std::string body;
+  auto res = cli.Get("/", params, Headers{}, [&](const char *data, size_t data_length) {
+    body.append(data, data_length);
+    return true;
+  });
+
+  ASSERT_TRUE(res);
+  EXPECT_EQ(200, res->status);
+  EXPECT_EQ("world", body);
+
+  svr.stop();
+  listen_thread.join();
+  ASSERT_FALSE(svr.is_running());
+}
+
 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
 TEST(KeepAliveTest, ReadTimeoutSSL) {
   SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);