From e444efb0047a112108d054834c8541662de929e9 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 24 Oct 2013 05:55:19 +0100 Subject: [PATCH] Fix HTTP redirects when running under HTTP/S --- Netdisco/Changes | 10 ++++++++-- Netdisco/lib/App/Netdisco/Web/AdminTask.pm | 4 +++- Netdisco/lib/App/Netdisco/Web/Device.pm | 3 ++- Netdisco/lib/App/Netdisco/Web/Search.pm | 8 +++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 1c695aaf..badfa54b 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,10 +1,16 @@ -2.019001 - 2013-10-08 +2.019002 - 2013-10-24 + + [BUG FIXES] + + * Fix HTTP redirects when running under HTTP/S + +2.019001 - 2013-10-22 [BUG FIXES] * Fix syntax error in Util/SNMP.pm -2.019000 - 2013-10-08 +2.019000 - 2013-10-22 [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/Web/AdminTask.pm b/Netdisco/lib/App/Netdisco/Web/AdminTask.pm index 3a600d2a..4ca0ea5f 100644 --- a/Netdisco/lib/App/Netdisco/Web/AdminTask.pm +++ b/Netdisco/lib/App/Netdisco/Web/AdminTask.pm @@ -55,7 +55,9 @@ foreach my $jobtype (keys %jobs_all, keys %jobs) { if exists $jobs{$jobtype} and not param('device'); add_job($jobtype, param('device'), param('extra')); - redirect uri_for('/admin/jobqueue')->path; + + header(Location => uri_for('/admin/jobqueue')->path); + return status(302); }; } diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 63574069..475cbac2 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -159,7 +159,8 @@ get '/device' => require_login sub { }); if (!defined $dev) { - return redirect uri_for('/', {nosuchdevice => 1})->path_query; + header(Location => uri_for('/', {nosuchdevice => 1})->path_query); + return status(302); } params->{'tab'} ||= 'details'; diff --git a/Netdisco/lib/App/Netdisco/Web/Search.pm b/Netdisco/lib/App/Netdisco/Web/Search.pm index 92f48675..2b5155bb 100644 --- a/Netdisco/lib/App/Netdisco/Web/Search.pm +++ b/Netdisco/lib/App/Netdisco/Web/Search.pm @@ -66,7 +66,8 @@ get '/search' => require_login sub { if (not param('tab')) { if (not $q) { - return redirect uri_for('/')->path; + header(Location => uri_for('/')->path); + return status(302); } # pick most likely tab for initial results @@ -79,11 +80,12 @@ get '/search' => require_login sub { if ($nd and $nd->count) { if ($nd->count == 1) { # redirect to device details for the one device - return redirect uri_for('/device', { + header(Location => uri_for('/device', { tab => 'details', q => ($nd->first->dns || $nd->first->ip), f => '', - })->path_query; + })->path_query); + return status(302); } # multiple devices