uvco 0.1
Loading...
Searching...
No Matches
uvco::examples::HttpResponse Struct Reference

#include <http_server.h>

Public Member Functions

 HttpResponse ()
std::string toString ()

Public Attributes

int statusCode = 200
std::string statusMessage = "OK"
std::vector< std::pair< std::string_view, std::string > > headers
std::string body

Constructor & Destructor Documentation

◆ HttpResponse()

uvco::examples::HttpResponse::HttpResponse ( )
21{ headers.reserve(8); }
std::vector< std::pair< std::string_view, std::string > > headers
Definition http_server.h:34

Member Function Documentation

◆ toString()

std::string uvco::examples::HttpResponse::toString ( )
23 {
24 headers.emplace_back("Content-Length", std::to_string(body.length()));
25 fmt::memory_buffer buf;
26 fmt::format_to(std::back_inserter(buf), "HTTP/1.1 {} {}\r\n", statusCode,
28 for (const auto &header : headers) {
29 fmt::format_to(std::back_inserter(buf), "{}: {}\r\n", header.first,
30 header.second);
31 }
32 fmt::format_to(std::back_inserter(buf), "\r\n");
33 fmt::format_to(std::back_inserter(buf), "{}", body);
34 return fmt::to_string(buf);
35}
std::string statusMessage
Definition http_server.h:33
std::string body
Definition http_server.h:35
int statusCode
Definition http_server.h:32

Member Data Documentation

◆ body

std::string uvco::examples::HttpResponse::body

◆ headers

std::vector<std::pair<std::string_view, std::string> > uvco::examples::HttpResponse::headers

◆ statusCode

int uvco::examples::HttpResponse::statusCode = 200

◆ statusMessage

std::string uvco::examples::HttpResponse::statusMessage = "OK"

The documentation for this struct was generated from the following files: