mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-25 18:22:59 +02:00 
			
		
		
		
	PageCompiler: add support for Cache-Control header
This commit is contained in:
		| @@ -272,6 +272,11 @@ is actually written to a string stream (<[std::ostringstream]>). | |||||||
| Sending of the HTTP response back to the client is deferred to | Sending of the HTTP response back to the client is deferred to | ||||||
| when the page is complete. | when the page is complete. | ||||||
|  |  | ||||||
|  | !cacheControl | ||||||
|  |  | ||||||
|  | If set to a non-empty string (e.g., "no-cache, no-store"), adds a "Cache-Control" | ||||||
|  | header to the response with the given argument as value. | ||||||
|  |  | ||||||
| !session (OSP only) | !session (OSP only) | ||||||
|  |  | ||||||
| For use with the POCO Open Service Platform only. | For use with the POCO Open Service Platform only. | ||||||
|   | |||||||
| @@ -311,6 +311,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 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)); | ||||||
| 	bool compressed(_page.getBool("page.compressed", false)); | 	bool compressed(_page.getBool("page.compressed", false)); | ||||||
| @@ -333,6 +334,10 @@ void CodeWriter::writeResponse(std::ostream& ostr) | |||||||
| 		ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\", \"gzip\"));\n" | 		ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\", \"gzip\"));\n" | ||||||
| 		     << "\tif (_compressResponse) response.set(\"Content-Encoding\", \"gzip\");\n"; | 		     << "\tif (_compressResponse) response.set(\"Content-Encoding\", \"gzip\");\n"; | ||||||
| 	} | 	} | ||||||
|  | 	if (!cacheControl.empty()) | ||||||
|  | 	{ | ||||||
|  | 		ostr << "\tresponse.set(\"Cache-Control\", \"" << cacheControl << "\");\n"; | ||||||
|  | 	} | ||||||
| 	ostr << "\n"; | 	ostr << "\n"; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Günter Obiltschnig
					Günter Obiltschnig