mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-08-03 12:50:02 +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;
|
break;
|
||||||
case Location:
|
case Location:
|
||||||
SPDLOG_TRACE(statuslog, "Response is a Location (redirect)");
|
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";
|
*m_stream_out << "Location: " << m_resp_value << "\n\n";
|
||||||
render_page = false;
|
render_page = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -127,8 +127,10 @@ namespace tawashi {
|
||||||
|
|
||||||
const SettingsBag& settings = this->settings();
|
const SettingsBag& settings = this->settings();
|
||||||
const auto max_sz = settings.as<uint32_t>("max_pastie_size");
|
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;
|
return;
|
||||||
|
}
|
||||||
if (max_sz and pastie.size() > max_sz) {
|
if (max_sz and pastie.size() > max_sz) {
|
||||||
if (settings.as<bool>("truncate_long_pasties")) {
|
if (settings.as<bool>("truncate_long_pasties")) {
|
||||||
pastie = pastie.substr(0, max_sz);
|
pastie = pastie.substr(0, max_sz);
|
||||||
|
@ -147,11 +149,13 @@ namespace tawashi {
|
||||||
if (token) {
|
if (token) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << base_uri() << '/' << *token;
|
oss << base_uri() << '/' << *token;
|
||||||
|
statuslog->info("Pastie token=\"{}\" redirect=\"{}\"", *token, oss.str());
|
||||||
if (not lang.empty())
|
if (not lang.empty())
|
||||||
oss << '?' << lang;
|
oss << '?' << lang;
|
||||||
this->change_type(Response::Location, oss.str());
|
this->change_type(Response::Location, oss.str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
statuslog->info("Empty pastie token (possibly due to a previous failure)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue