From: David ‘Bombe’ Roden Date: Sat, 6 Dec 2014 22:07:54 +0000 (+0100) Subject: Add refresh header to rescue page. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=01e37a5196463006ce4ce4e1f505971af794817f;p=Sone.git Add refresh header to rescue page. --- 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(); + } + }