From 10da75caf5f918283635a7168c1349f8888f432d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 12 May 2017 09:18:49 +0100 Subject: [PATCH] Remove parameters from Response's constructor. They can safely be defaulted and derived classes can change their preferences later inside their constructor if they need to. --- src/tawashi_implem/index_response.cpp | 2 +- src/tawashi_implem/pastie_response.cpp | 2 +- src/tawashi_implem/response.cpp | 8 ++++---- src/tawashi_implem/response.hpp | 2 -- src/tawashi_implem/submit_paste_response.cpp | 3 ++- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tawashi_implem/index_response.cpp b/src/tawashi_implem/index_response.cpp index e64b356..76847f0 100644 --- a/src/tawashi_implem/index_response.cpp +++ b/src/tawashi_implem/index_response.cpp @@ -24,7 +24,7 @@ namespace tawashi { std::ostream* parStreamOut, const Kakoune::SafePtr& parCgiEnv ) : - Response(Response::ContentType, "text/html", parSettings, parStreamOut, parCgiEnv, false) + Response(parSettings, parStreamOut, parCgiEnv, false) { } } //namespace tawashi diff --git a/src/tawashi_implem/pastie_response.cpp b/src/tawashi_implem/pastie_response.cpp index af30636..18df2b2 100644 --- a/src/tawashi_implem/pastie_response.cpp +++ b/src/tawashi_implem/pastie_response.cpp @@ -35,7 +35,7 @@ namespace tawashi { std::ostream* parStreamOut, const Kakoune::SafePtr& parCgiEnv ) : - Response(Response::ContentType, "text/html", parSettings, parStreamOut, parCgiEnv, true), + Response(parSettings, parStreamOut, parCgiEnv, true), m_langmap_dir(parSettings->as("langmap_dir")), m_plain_text(false), m_syntax_highlight(true) diff --git a/src/tawashi_implem/response.cpp b/src/tawashi_implem/response.cpp index a92a5e0..fe32365 100644 --- a/src/tawashi_implem/response.cpp +++ b/src/tawashi_implem/response.cpp @@ -34,6 +34,8 @@ namespace tawashi { namespace { + const char g_def_response_type[] = "text/html"; + //boost::string_ref fetch_page_basename (const cgi::Env& parEnv) { // const boost::string_ref& path = parEnv.path_info(); @@ -106,19 +108,17 @@ namespace tawashi { } //unnamed namespace Response::Response ( - Types parRespType, - std::string&& parValue, const Kakoune::SafePtr& parSettings, std::ostream* parStreamOut, const Kakoune::SafePtr& parCgiEnv, bool parWantRedis ) : - m_resp_value(std::move(parValue)), + m_resp_value(g_def_response_type), //m_page_basename(fetch_page_basename(m_cgi_env)), m_cgi_env(parCgiEnv), m_settings(parSettings), m_website_root(make_root_path(*parSettings)), - m_resp_type(parRespType), + m_resp_type(ContentType), m_stream_out(parStreamOut), m_header_sent(false) { diff --git a/src/tawashi_implem/response.hpp b/src/tawashi_implem/response.hpp index da524b3..b84f01b 100644 --- a/src/tawashi_implem/response.hpp +++ b/src/tawashi_implem/response.hpp @@ -48,8 +48,6 @@ namespace tawashi { }; Response ( - Types parRespType, - std::string&& parValue, const Kakoune::SafePtr& parSettings, std::ostream* parStreamOut, const Kakoune::SafePtr& parCgiEnv, diff --git a/src/tawashi_implem/submit_paste_response.cpp b/src/tawashi_implem/submit_paste_response.cpp index 6ee1ab6..1b0820d 100644 --- a/src/tawashi_implem/submit_paste_response.cpp +++ b/src/tawashi_implem/submit_paste_response.cpp @@ -94,8 +94,9 @@ namespace tawashi { std::ostream* parStreamOut, const Kakoune::SafePtr& parCgiEnv ) : - Response(Response::ContentType, "text/plain", parSettings, parStreamOut, parCgiEnv, true) + Response(parSettings, parStreamOut, parCgiEnv, true) { + this->change_type(Response::ContentType, "text/plain"); } void SubmitPasteResponse::on_process() {