1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2025-02-09 09:23:56 +00:00

Fix tawashi sending back an html response even for redirects.

This commit is contained in:
King_DuckZ 2017-05-16 22:58:09 +01:00
parent f19d78222f
commit 85f6781d81
2 changed files with 19 additions and 13 deletions

View file

@ -177,6 +177,7 @@ namespace tawashi {
this->on_mustache_prepare(mustache_context); this->on_mustache_prepare(mustache_context);
m_header_sent = true; m_header_sent = true;
bool render_page = true;
switch (m_resp_type) { switch (m_resp_type) {
case ContentType: case ContentType:
SPDLOG_TRACE(statuslog, "Response is a Content-type (data)"); SPDLOG_TRACE(statuslog, "Response is a Content-type (data)");
@ -185,21 +186,25 @@ namespace tawashi {
case Location: case Location:
SPDLOG_TRACE(statuslog, "Response is a Location (redirect)"); SPDLOG_TRACE(statuslog, "Response is a Location (redirect)");
*m_stream_out << "Location: " << m_resp_value << "\n\n"; *m_stream_out << "Location: " << m_resp_value << "\n\n";
render_page = false;
break; break;
} }
SPDLOG_TRACE(statuslog, "Rendering in mustache"); if (render_page) {
*m_stream_out << mstch::render( SPDLOG_TRACE(statuslog, "Rendering in mustache");
on_mustache_retrieve(), *m_stream_out << mstch::render(
mustache_context, on_mustache_retrieve(),
std::bind( mustache_context,
&load_whole_file, std::bind(
std::cref(m_website_root), &load_whole_file,
".mustache", std::cref(m_website_root),
std::placeholders::_1, ".mustache",
false std::placeholders::_1,
) false
); )
);
}
SPDLOG_TRACE(statuslog, "Flushing output"); SPDLOG_TRACE(statuslog, "Flushing output");
m_stream_out->flush(); m_stream_out->flush();
} }

View file

@ -22,6 +22,7 @@
#include <string> #include <string>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/utility/string_ref.hpp> #include <boost/utility/string_ref.hpp>
#include <cassert>
namespace tawashi { namespace tawashi {
class SubmitPasteResponse : public Response { class SubmitPasteResponse : public Response {
@ -33,7 +34,7 @@ namespace tawashi {
); );
protected: protected:
virtual boost::string_ref page_basename() const override { return boost::string_ref("paste"); } virtual boost::string_ref page_basename() const override { assert(false); return boost::string_ref(""); }
private: private:
virtual void on_process() override; virtual void on_process() override;