From 9a630573219dc555088b80374a6630709328d9ea 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:44 +0100 Subject: [PATCH] Allow pages to add HTTP headers to the response. --- .../net/pterodactylus/sone/web/page/FreenetTemplatePage.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java index 40e19b1..14e48ac 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java @@ -33,6 +33,7 @@ import java.util.logging.Logger; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.template.TemplateContextFactory; +import net.pterodactylus.util.web.Header; import net.pterodactylus.util.web.Method; import net.pterodactylus.util.web.Page; import net.pterodactylus.util.web.RedirectResponse; @@ -168,6 +169,12 @@ public class FreenetTemplatePage implements FreenetPage, LinkEnabledCallback { postProcess(request, templateContext); + for (Header header : getAdditionalHeaders(request)) { + for (String value : header) { + response.addHeader(header.getName(), value); + } + } + return response.setStatusCode(200).setStatusText("OK").setContentType("text/html").write(pageNode.outer.generate()); } @@ -236,6 +243,10 @@ public class FreenetTemplatePage implements FreenetPage, LinkEnabledCallback { return null; } + protected Iterable
getAdditionalHeaders(FreenetRequest request) { + return Collections.emptyList(); + } + /** * Returns additional <link> nodes for the HTML’s <head> node. * -- 2.7.4