1#include "HTTPResponse.h"
9 return format(
"{:%a, %d %b %Y %H:%M:%OS} GMT", chrono::system_clock::now());
12 HTTPResponse::HTTPResponse()
19 this->builder = builder;
26 builder.HTTPVersion(version);
31 builder.responseCode(code);
51 "Content-Type",
"application/json"
54 this->body = json.build();
59 this->body = move(body);
73 "Set-Cookie", name +
"=" + value
81 builder.responseCode(web::responseCodes::ok);
85 this->setIsValid(
true);
88 void HTTPResponse::setIsValid(
bool isValid)
90 this->isValid = isValid;
93 HTTPResponse::operator bool()
const
98 streams::IOSocketStream& operator << (streams::IOSocketStream& stream,
HTTPResponse& response)
102 response.builder.headers
105 "Server",
"WebFramework-Server"
108 if (response.body.size())
110 result = response.builder.build(response.body);
114 result = response.builder.build();
HTTPResponse & operator=(const web::HTTPBuilder &builder)
Assign operator for HTTPBuilder.
HTTPResponse & appendBody(const std::string &body)
void addCookie(const std::string &name, const std::string &value)
Add cookie to HTTP response.
void addBody(const std::string &body)
static std::string getFullDate()
Adds full date GMT to response.
void addHeader(const std::string &name, const std::string &value)
Set additional HTTP header.
void setDefault()
Clears HTTPResponse.
void setResponseCode(web::responseCodes code)
Set HTTP response code.
void setHTTPVersion(const std::string &version)