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,9 +186,11 @@ 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;
} }
if (render_page) {
SPDLOG_TRACE(statuslog, "Rendering in mustache"); SPDLOG_TRACE(statuslog, "Rendering in mustache");
*m_stream_out << mstch::render( *m_stream_out << mstch::render(
on_mustache_retrieve(), on_mustache_retrieve(),
@ -200,6 +203,8 @@ namespace tawashi {
false 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;