diff --git a/src/tawashi/response.cpp b/src/tawashi/response.cpp index 8691643..e9ebb85 100644 --- a/src/tawashi/response.cpp +++ b/src/tawashi/response.cpp @@ -214,7 +214,7 @@ namespace tawashi { return *m_cgi_env; } - cgi::PostMapType Response::cgi_post() const { + const cgi::PostMapType& Response::cgi_post() const { return cgi::read_post(std::cin, cgi_env(), settings().as("max_post_size")); } diff --git a/src/tawashi/response.hpp b/src/tawashi/response.hpp index b47ad9d..1e11f59 100644 --- a/src/tawashi/response.hpp +++ b/src/tawashi/response.hpp @@ -50,7 +50,7 @@ namespace tawashi { ); const cgi::Env& cgi_env() const; - tawashi_virtual_testing cgi::PostMapType cgi_post() const; + tawashi_virtual_testing const cgi::PostMapType& cgi_post() const; const std::string& base_uri() const; virtual boost::string_view page_basename() const = 0; diff --git a/src/tawashi/submit_paste_response.cpp b/src/tawashi/submit_paste_response.cpp index 3775839..57705c1 100644 --- a/src/tawashi/submit_paste_response.cpp +++ b/src/tawashi/submit_paste_response.cpp @@ -104,7 +104,7 @@ namespace tawashi { const SettingsBag& settings = this->settings(); try { - auto post = this->cgi_post(); + auto& post = this->cgi_post(); pastie = get_value_from_post(post, make_string_view(g_post_key)); lang = get_value_from_post_log_failure(post, make_string_view(g_language_key)); duration = get_value_from_post_log_failure(post, make_string_view(g_duration_key)); diff --git a/test/simulation/test_submit_pastie.cpp b/test/simulation/test_submit_pastie.cpp index 66185a2..7853665 100644 --- a/test/simulation/test_submit_pastie.cpp +++ b/test/simulation/test_submit_pastie.cpp @@ -44,7 +44,7 @@ namespace tawashi { { } - virtual cgi::PostMapType cgi_post() const override { + virtual const cgi::PostMapType& cgi_post() const override { CHECK(not m_post_data.empty()); std::istringstream iss(m_post_data); return cgi::read_post(iss, this->cgi_env(), this->settings().as("max_post_size"));