From 01e37a5196463006ce4ce4e1f505971af794817f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 6 Dec 2014 23:07:54 +0100 Subject: [PATCH] Add refresh header to rescue page. --- src/main/java/net/pterodactylus/sone/web/RescuePage.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/RescuePage.java b/src/main/java/net/pterodactylus/sone/web/RescuePage.java index 24a8f11..1ba86e9 100644 --- a/src/main/java/net/pterodactylus/sone/web/RescuePage.java +++ b/src/main/java/net/pterodactylus/sone/web/RescuePage.java @@ -19,11 +19,15 @@ package net.pterodactylus.sone.web; import static net.pterodactylus.sone.utils.NumberParsers.parseLong; +import java.util.Arrays; +import java.util.Collections; + import net.pterodactylus.sone.core.SoneRescuer; import net.pterodactylus.sone.data.LocalSone; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Header; import net.pterodactylus.util.web.Method; /** @@ -71,4 +75,16 @@ public class RescuePage extends SoneTemplatePage { templateContext.set("soneRescuer", soneRescuer); } + @Override + protected Iterable
getAdditionalHeaders(FreenetRequest request) { + LocalSone currentSone = getCurrentSone(request.getToadletContext(), false).get(); + SoneRescuer soneRescuer = webInterface.getCore().getSoneRescuer(currentSone); + if ((request.getMethod() == Method.GET) && soneRescuer.isFetching()) { + final Header header = new Header("Refresh"); + header.addValue("5; url=rescue.html"); + return Arrays.asList(header); + } + return Collections.emptyList(); + } + } -- 2.7.4