output/httpd: use libfmt
This commit is contained in:
parent
ce0b4d5c19
commit
17f2c0ae88
@ -11,11 +11,11 @@
|
|||||||
#include "net/UniqueSocketDescriptor.hxx"
|
#include "net/UniqueSocketDescriptor.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
HttpdClient::~HttpdClient() noexcept
|
HttpdClient::~HttpdClient() noexcept
|
||||||
{
|
{
|
||||||
if (IsDefined())
|
if (IsDefined())
|
||||||
@ -119,7 +119,6 @@ HttpdClient::HandleLine(const char *line) noexcept
|
|||||||
bool
|
bool
|
||||||
HttpdClient::SendResponse() noexcept
|
HttpdClient::SendResponse() noexcept
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
|
||||||
std::string allocated;
|
std::string allocated;
|
||||||
const char *response;
|
const char *response;
|
||||||
|
|
||||||
@ -140,16 +139,15 @@ HttpdClient::SendResponse() noexcept
|
|||||||
metaint);
|
metaint);
|
||||||
response = allocated.c_str();
|
response = allocated.c_str();
|
||||||
} else { /* revert to a normal HTTP request */
|
} else { /* revert to a normal HTTP request */
|
||||||
snprintf(buffer, sizeof(buffer),
|
allocated = fmt::format("HTTP/1.1 200 OK\r\n"
|
||||||
"HTTP/1.1 200 OK\r\n"
|
"Content-Type: {}\r\n"
|
||||||
"Content-Type: %s\r\n"
|
|
||||||
"Connection: close\r\n"
|
"Connection: close\r\n"
|
||||||
"Pragma: no-cache\r\n"
|
"Pragma: no-cache\r\n"
|
||||||
"Cache-Control: no-cache, no-store\r\n"
|
"Cache-Control: no-cache, no-store\r\n"
|
||||||
"Access-Control-Allow-Origin: *\r\n"
|
"Access-Control-Allow-Origin: *\r\n"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
httpd.content_type);
|
httpd.content_type);
|
||||||
response = buffer;
|
response = allocated.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t nbytes = GetSocket().Write(response, strlen(response));
|
ssize_t nbytes = GetSocket().Write(response, strlen(response));
|
||||||
|
Loading…
Reference in New Issue
Block a user