2
0
Эх сурвалжийг харах

#4071: PageCompiler: add referrerPolicy to page directive

Günter Obiltschnig 2 жил өмнө
parent
commit
64b5a91ca1

+ 4 - 0
PageCompiler/doc/PageCompilerUserGuide.page

@@ -273,6 +273,10 @@ header in the request.
 
 Allows to specify the value of the HTTP Content-Security-Policy header.
 
+!referrerPolicy
+
+Allows to specify the value of the HTTP Referrer-Policy header.
+
 !chunked
 
 Allows you to specify whether the response is sent using chunked transfer encoding.

+ 5 - 0
PageCompiler/src/CodeWriter.cpp

@@ -317,6 +317,7 @@ void CodeWriter::writeResponse(std::ostream& ostr)
 	std::string contentType(_page.get("page.contentType", "text/html"));
 	std::string contentLang(_page.get("page.contentLanguage", ""));
 	std::string contentSecurityPolicy(_page.get("page.contentSecurityPolicy", ""));
+	std::string referrerPolicy(_page.get("page.referrerPolicy", ""));
 	std::string cacheControl(_page.get("page.cacheControl", ""));
 	bool buffered(_page.getBool("page.buffered", false));
 	bool chunked(_page.getBool("page.chunked", !buffered));
@@ -339,6 +340,10 @@ void CodeWriter::writeResponse(std::ostream& ostr)
 	{
 		ostr << "\tresponse.set(\"Content-Security-Policy\"s, \"" << contentSecurityPolicy << "\"s);\n";
 	}
+	if (!referrerPolicy.empty())
+	{
+		ostr << "\tresponse.set(\"Referrer-Policy\"s, \"" << referrerPolicy << "\"s);\n";
+	}
 	if (compressed)
 	{
 		ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\"s, \"gzip\"s));\n"

+ 1 - 1
PageCompiler/src/PageCompiler.cpp

@@ -216,7 +216,7 @@ protected:
 		helpFormatter.setHeader(
 			"\n"
 			"The POCO C++ Server Page Compiler.\n"
-			"Copyright (c) 2008-2022 by Applied Informatics Software Engineering GmbH.\n"
+			"Copyright (c) 2008-2023 by Applied Informatics Software Engineering GmbH.\n"
 			"All rights reserved.\n\n"
 			"This program compiles web pages containing embedded C++ code "
 			"into a C++ class that can be used with the HTTP server "