From 17f2c0ae881332c8a99628dca8e7f7d7423261f5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 19:53:37 +0100 Subject: [PATCH] output/httpd: use libfmt --- src/output/plugins/httpd/HttpdClient.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx index b07b286a2..fdaf4a5e7 100644 --- a/src/output/plugins/httpd/HttpdClient.cxx +++ b/src/output/plugins/httpd/HttpdClient.cxx @@ -11,11 +11,11 @@ #include "net/UniqueSocketDescriptor.hxx" #include "Log.hxx" +#include + #include #include -#include - HttpdClient::~HttpdClient() noexcept { if (IsDefined()) @@ -119,7 +119,6 @@ HttpdClient::HandleLine(const char *line) noexcept bool HttpdClient::SendResponse() noexcept { - char buffer[1024]; std::string allocated; const char *response; @@ -140,16 +139,15 @@ HttpdClient::SendResponse() noexcept metaint); response = allocated.c_str(); } else { /* revert to a normal HTTP request */ - snprintf(buffer, sizeof(buffer), - "HTTP/1.1 200 OK\r\n" - "Content-Type: %s\r\n" - "Connection: close\r\n" - "Pragma: no-cache\r\n" - "Cache-Control: no-cache, no-store\r\n" - "Access-Control-Allow-Origin: *\r\n" - "\r\n", - httpd.content_type); - response = buffer; + allocated = fmt::format("HTTP/1.1 200 OK\r\n" + "Content-Type: {}\r\n" + "Connection: close\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache, no-store\r\n" + "Access-Control-Allow-Origin: *\r\n" + "\r\n", + httpd.content_type); + response = allocated.c_str(); } ssize_t nbytes = GetSocket().Write(response, strlen(response));