mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2024-11-27 00:43:47 +00:00
Try to fix redirect not working properly.
This commit is contained in:
parent
5a4794240b
commit
59a5d35ee0
2 changed files with 6 additions and 1 deletions
|
@ -185,6 +185,7 @@ namespace tawashi {
|
|||
break;
|
||||
case Location:
|
||||
SPDLOG_TRACE(statuslog, "Response is a Location (redirect)");
|
||||
*m_stream_out << "Status: 303 See Other" << "\n";
|
||||
*m_stream_out << "Location: " << m_resp_value << "\n\n";
|
||||
render_page = false;
|
||||
break;
|
||||
|
|
|
@ -127,8 +127,10 @@ namespace tawashi {
|
|||
|
||||
const SettingsBag& settings = this->settings();
|
||||
const auto max_sz = settings.as<uint32_t>("max_pastie_size");
|
||||
if (pastie.size() < settings.as<uint32_t>("min_pastie_size"))
|
||||
if (pastie.size() < settings.as<uint32_t>("min_pastie_size")) {
|
||||
error_redirect(431, ErrorReasons::PostLengthNotInRange);
|
||||
return;
|
||||
}
|
||||
if (max_sz and pastie.size() > max_sz) {
|
||||
if (settings.as<bool>("truncate_long_pasties")) {
|
||||
pastie = pastie.substr(0, max_sz);
|
||||
|
@ -147,11 +149,13 @@ namespace tawashi {
|
|||
if (token) {
|
||||
std::ostringstream oss;
|
||||
oss << base_uri() << '/' << *token;
|
||||
statuslog->info("Pastie token=\"{}\" redirect=\"{}\"", *token, oss.str());
|
||||
if (not lang.empty())
|
||||
oss << '?' << lang;
|
||||
this->change_type(Response::Location, oss.str());
|
||||
}
|
||||
else {
|
||||
statuslog->info("Empty pastie token (possibly due to a previous failure)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue