FU: Preserve existing headers on fu->redirect()

Allows setting custom headers (in particular, cookies) when redirecting.
This behavior is consistent with send_file().
This commit is contained in:
Yorhel 2025-05-04 12:18:12 +02:00
parent 6787f32fd9
commit 52c36e0aea

1
FU.pm
View file

@ -862,7 +862,6 @@ sub send_file($, $root, $path) {
sub redirect($, $code, $location) { sub redirect($, $code, $location) {
state $alias = {qw/ perm 301 temp 302 tempget 303 tempsame 307 permsame 308 /}; state $alias = {qw/ perm 301 temp 302 tempget 303 tempsame 307 permsame 308 /};
fu->reset;
fu->status($alias->{$code} // $code); fu->status($alias->{$code} // $code);
fu->set_header(location => "$location"); fu->set_header(location => "$location");
fu->set_header('content-type', 'text/plain'); fu->set_header('content-type', 'text/plain');