From: David ‘Bombe’ Roden Date: Sat, 6 Dec 2014 22:07:44 +0000 (+0100) Subject: Allow pages to add HTTP headers to the response. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9a630573219dc555088b80374a6630709328d9ea;p=Sone.git Allow pages to add HTTP headers to the response. --- 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. *