23#include <core/exception.h>
24#include <webview/reply.h>
61bool WebReply::caching_default_ =
true;
71 caching_ = caching_default_;
88 caching_default_ = caching;
125 headers_[header] = content;
134 std::string::size_type pos;
135 if ((pos = header_string.find(
":")) != std::string::npos) {
136 std::string header = header_string.substr(0, pos);
138 if (header_string[pos + 1] ==
' ') {
139 content = header_string.substr(pos + 2);
141 content = header_string.substr(pos + 1);
143 headers_[header] = content;
145 throw Exception(
"Invalid header '%s'", header_string.c_str());
185 headers_[
"Cache-Control"] =
"no-cache, no-store, must-revalidate, max-age=0";
256 va_start(args, format);
258 if (vasprintf(&s, format, args) != -1) {
297std::string::size_type
300 return _body.length();
DynamicWebReply(Code code)
Constructor.
virtual size_t chunk_size()
Chunksize.
Base class for exceptions in Fawkes.
StaticWebReply & operator+=(std::string text)
Append simple text line.
StaticWebReply(Code code, std::string body="")
Constructor.
void append_body(const char *format,...)
Append to body.
std::string _body
Body of the reply.
virtual std::string::size_type body_length()
Get length of body.
virtual const std::string & body()
Get body.
virtual void pack()
Pack the data.
void set_code(Code code)
Set response code.
virtual ~WebReply()
Destructor.
std::map< std::string, std::string > HeaderMap
Map of headers.
static void set_caching_default(bool caching)
Enable or disable caching default for replies.
void set_caching(bool caching)
Enable or disable caching for this specific reply.
void add_header(const std::string &header, const std::string &content)
Add a HTTP header.
Code code() const
Get response code.
void set_request(WebRequest *request)
Set associated request.
WebReply(Code code)
Constructor.
const HeaderMap & headers() const
get headers.
WebRequest * get_request() const
Get associated request.
void pack_caching()
Called just before the reply is sent.
Web request meta data carrier.
Fawkes library namespace.
WebReply * no_caching(WebReply *reply)
Disable caching on a reply.