1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2025-10-14 15:20:36 +00:00

Redirect to the new page if pastie was successful.

This commit is contained in:
King_DuckZ 2017-04-07 00:31:06 +01:00
commit ef9e74c473
6 changed files with 71 additions and 20 deletions

View file

@ -17,22 +17,47 @@
#include "response.hpp"
#include <utility>
#include <cassert>
namespace tawashi {
Response::Response (std::string&& parType) :
m_content_type(std::move(parType))
Response::Response (Types parRespType, std::string&& parValue) :
m_resp_value(std::move(parValue)),
m_resp_type(parRespType),
m_header_sent(false)
{
}
Response::~Response() noexcept = default;
void Response::on_process() {
}
void Response::send() {
std::cout << "Content-type:" << m_content_type << "\n\n";
this->on_send(std::cout);
this->on_process();
m_header_sent = true;
switch (m_resp_type) {
case ContentType:
std::cout << "Content-type: " << m_resp_value << "\n\n";
break;
case Location:
std::cout << "Location: " << m_resp_value << "\n\n";
break;
}
if (ContentType == m_resp_type)
this->on_send(std::cout);
std::cout.flush();
}
const cgi::Env& Response::cgi_env() const {
return m_cgi_env;
}
void Response::change_type (Types parRespType, std::string&& parValue) {
assert(not m_header_sent);
assert(not parValue.empty());
m_resp_type = parRespType;
m_resp_value = std::move(parValue);
}
} //namespace tawashi