Fix redirect in Dancer to not forcibly apply scheme+host

This commit is contained in:
Oliver Gorwits
2013-10-27 03:05:28 +00:00
parent c0c8edf6f0
commit f90f2b0a67
5 changed files with 26 additions and 10 deletions

View File

@@ -1,3 +1,13 @@
2.019003 -
[ENHANCEMENTS]
* Use cursor to greatly speed up macsuck/arpnip startup code (jeneric)
[BUG FIXES]
* Fix redirect in Dancer to not forcibly apply scheme+host
2.019002 - 2013-10-24
[BUG FIXES]

View File

@@ -100,4 +100,15 @@ any qr{.*} => sub {
template 'index';
};
{
# https://github.com/PerlDancer/Dancer/issues/967
no warnings 'redefine';
*Dancer::_redirect = sub {
my ($destination, $status) = @_;
my $response = Dancer::SharedData->response;
$response->status($status || 302);
$response->headers('Location' => $destination);
};
}
true;

View File

@@ -55,9 +55,7 @@ foreach my $jobtype (keys %jobs_all, keys %jobs) {
if exists $jobs{$jobtype} and not param('device');
add_job($jobtype, param('device'), param('extra'));
header(Location => uri_for('/admin/jobqueue')->path);
return status(302);
redirect uri_for('/admin/jobqueue')->path;
};
}

View File

@@ -159,8 +159,7 @@ get '/device' => require_login sub {
});
if (!defined $dev) {
header(Location => uri_for('/', {nosuchdevice => 1})->path_query);
return status(302);
return redirect uri_for('/', {nosuchdevice => 1})->path_query;
}
params->{'tab'} ||= 'details';

View File

@@ -66,8 +66,7 @@ get '/search' => require_login sub {
if (not param('tab')) {
if (not $q) {
header(Location => uri_for('/')->path);
return status(302);
return redirect uri_for('/')->path;
}
# pick most likely tab for initial results
@@ -80,12 +79,11 @@ get '/search' => require_login sub {
if ($nd and $nd->count) {
if ($nd->count == 1) {
# redirect to device details for the one device
header(Location => uri_for('/device', {
return redirect uri_for('/device', {
tab => 'details',
q => ($nd->first->dns || $nd->first->ip),
f => '',
})->path_query);
return status(302);
})->path_query;
}
# multiple devices