WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
HTTPResponse.h
1#pragma once
2
3#include "Import/WebFrameworkCore.h"
4
5#include "HTTPBuilder.h"
6#include "IOSocketStream.h"
7
8namespace framework
9{
14 class WEB_FRAMEWORK_API HTTPResponse
15 {
16 private:
17 web::HTTPBuilder builder;
18 std::string body;
19 bool isValid;
20
21 public:
26 static std::string getFullDate();
27
28 public:
30
36 HTTPResponse& operator = (const web::HTTPBuilder& builder);
37
43 void setHTTPVersion(const std::string& version);
44
49 void setResponseCode(web::responseCodes code);
50
56 void addHeader(const std::string& name, const std::string& value);
57
63 void addBody(const std::string& body);
64
70 void addBody(const json::JSONBuilder& json);
71
77 void addBody(std::string&& body) noexcept;
78
85 HTTPResponse& appendBody(const std::string& body);
86
92 void addCookie(const std::string& name, const std::string& value);
93
97 void setDefault();
98
99 void setIsValid(bool isValid);
100
104 explicit operator bool() const;
105
113 friend streams::IOSocketStream& operator << (streams::IOSocketStream& stream, HTTPResponse& response);
114
115 ~HTTPResponse() = default;
116 };
117}
HTTPBuilder wrapper.
void addBody(const std::string &body)
void addBody(std::string &&body) noexcept