Support HSTS in Clickhouse HTTP server

This commit is contained in:
凌涛 2021-09-29 16:37:12 +08:00
parent ec26768dce
commit c298fba774

View File

@ -101,7 +101,17 @@ static inline void trySendExceptionToClient(
void StaticRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response) void StaticRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response)
{ {
auto keep_alive_timeout = server.config().getUInt("keep_alive_timeout", 10); const auto & config = server.config();
auto keep_alive_timeout = config.getUInt("keep_alive_timeout", 10);
size_t hsts_max_age = config.getUInt64("hsts_max_age", 0);
if (hsts_max_age > 0)
{
std::stringstream ss;
ss << "max-age=" << hsts_max_age;
response.add("Strict-Transport-Security", ss.str());
}
const auto & out = responseWriteBuffer(request, response, keep_alive_timeout); const auto & out = responseWriteBuffer(request, response, keep_alive_timeout);
try try