23 #include <webview/reply.h> 25 #include <core/exception.h> 45 bool WebReply::__caching =
true;
50 WebReply::WebReply(
Code code)
57 __headers[
"Cache-Control"] =
"no-cache, no-store, must-revalidate";
58 __headers[
"Pragma"] =
"no-cache";
59 __headers[
"Expires"] =
"0";
77 WebReply::set_caching(
bool caching)
86 WebReply::code()
const 97 WebReply::add_header(std::string header, std::string content)
99 __headers[header] = content;
107 WebReply::add_header(std::string header_string)
109 std::string::size_type pos;
110 if ((pos = header_string.find(
":")) != std::string::npos) {
111 std::string header = header_string.substr(0, pos);
113 if (header_string[pos+1] ==
' ') {
114 content = header_string.substr(pos+2);
116 content = header_string.substr(pos+1);
118 __headers[header] = content;
120 throw Exception(
"Invalid header '%s'", header_string.c_str());
129 WebReply::headers()
const 140 WebReply::get_request()
const 182 DynamicWebReply::DynamicWebReply(
Code code)
227 va_start(args, format);
229 if ( vasprintf(&s, format, args) != -1 ) {
262 std::string::size_type
265 return _body.length();
virtual size_t chunk_size()
Chunksize.
Fawkes library namespace.
std::string _body
Body of the reply.
virtual const std::string & body()
Get body.
StaticWebReply(Code code, std::string body="")
Constructor.
Base class for exceptions in Fawkes.
std::map< std::string, std::string > HeaderMap
Map of headers.
Web request meta data carrier.
void append_body(const char *format,...)
Append to body.
StaticWebReply & operator+=(std::string text)
Append simple text line.
virtual void pack()
Pack the data.
virtual std::string::size_type body_length()
Get length of body.