aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Response.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-01-17 15:52:38 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-01-17 15:54:08 +0000
commitf41b1719cc8f807912696a6728b20c0a2252e5a9 (patch)
tree5a8f8c3a22b6d3a92451dfebe075027ab89b27fc /perllib/FixMyStreet/App/Response.pm
parent38e8516818513f082bfac6d4631ed2b8ec300329 (diff)
In Edge 14, do all HTTP redirects in HTML instead.
This is to work around https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8572187/
Diffstat (limited to 'perllib/FixMyStreet/App/Response.pm')
-rw-r--r--perllib/FixMyStreet/App/Response.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Response.pm b/perllib/FixMyStreet/App/Response.pm
new file mode 100644
index 000000000..16ebf995f
--- /dev/null
+++ b/perllib/FixMyStreet/App/Response.pm
@@ -0,0 +1,27 @@
+# This package exists to try and work around a big bug in Edge:
+# https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8572187/
+
+package FixMyStreet::App::Response;
+use Moose;
+extends 'Catalyst::Response';
+
+around 'redirect' => sub {
+ my $orig = shift;
+ my $self = shift;
+ my ($location, $status) = @_;
+
+ return $self->$orig() unless @_; # getter
+
+ my $agent = $self->_context->request->user_agent;
+ return $self->$orig(@_) unless $agent =~ /Edge\/14/; # Only care about Edge
+
+ # Instead of a redirect, output HTML that redirects
+ $self->body(<<END
+<meta http-equiv="refresh" content="0; url=$location">
+Please follow this link: <a href="$location">$location</a>
+END
+ );
+ return $location;
+};
+
+1;