#4071: PageCompiler: add referrerPolicy to page directive

This commit is contained in:
Günter Obiltschnig
2023-07-10 21:27:24 +02:00
parent 4c1e83b8e8
commit 64b5a91ca1
3 changed files with 10 additions and 1 deletions

View File

@@ -273,6 +273,10 @@ header in the request.
Allows to specify the value of the HTTP Content-Security-Policy header. 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 !chunked
Allows you to specify whether the response is sent using chunked transfer encoding. Allows you to specify whether the response is sent using chunked transfer encoding.

View File

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

View File

@@ -216,7 +216,7 @@ protected:
helpFormatter.setHeader( helpFormatter.setHeader(
"\n" "\n"
"The POCO C++ Server Page Compiler.\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" "All rights reserved.\n\n"
"This program compiles web pages containing embedded C++ code " "This program compiles web pages containing embedded C++ code "
"into a C++ class that can be used with the HTTP server " "into a C++ class that can be used with the HTTP server "