From ed1343bd7bf9d27284dad42d2596742282f4cbd5 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 10 May 2017 20:42:42 +0100 Subject: [PATCH] Pass the istream to read_post instead of assuming std::cin. --- src/tawashi_implem/cgi_post.cpp | 4 ++-- src/tawashi_implem/cgi_post.hpp | 3 ++- src/tawashi_implem/submit_paste_response.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tawashi_implem/cgi_post.cpp b/src/tawashi_implem/cgi_post.cpp index c88d094..4c9e583 100644 --- a/src/tawashi_implem/cgi_post.cpp +++ b/src/tawashi_implem/cgi_post.cpp @@ -32,7 +32,7 @@ namespace tawashi { namespace { } //unnamed namespace - const PostMapType& read_post (const Env& parEnv) { + const PostMapType& read_post (std::istream& parSrc, const Env& parEnv) { static bool already_read = false; static PostMapType map; static std::string original_data; @@ -45,7 +45,7 @@ namespace tawashi { if (input_len > 0) { original_data.reserve(input_len); std::copy_n( - std::istream_iterator(std::cin), + std::istream_iterator(parSrc), input_len, std::back_inserter(original_data) ); diff --git a/src/tawashi_implem/cgi_post.hpp b/src/tawashi_implem/cgi_post.hpp index abcc972..b445bc8 100644 --- a/src/tawashi_implem/cgi_post.hpp +++ b/src/tawashi_implem/cgi_post.hpp @@ -19,6 +19,7 @@ #include #include +#include namespace tawashi { @@ -27,6 +28,6 @@ namespace tawashi { typedef boost::container::flat_map PostMapType; - const PostMapType& read_post (const Env& parEnv); + const PostMapType& read_post (std::istream& parSrc, const Env& parEnv); } //namespace cgi } //namespace tawashi diff --git a/src/tawashi_implem/submit_paste_response.cpp b/src/tawashi_implem/submit_paste_response.cpp index 428f334..7f4f556 100644 --- a/src/tawashi_implem/submit_paste_response.cpp +++ b/src/tawashi_implem/submit_paste_response.cpp @@ -70,7 +70,7 @@ namespace tawashi { } void SubmitPasteResponse::on_process() { - auto post = cgi::read_post(cgi_env()); + auto post = cgi::read_post(std::cin, cgi_env()); boost::string_ref pastie; boost::string_ref lang; boost::string_ref duration;