23 #include <core/exception.h> 24 #include <webview/reply.h> 61 bool 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) {
297 std::string::size_type
300 return _body.length();
const HeaderMap & headers() const
get headers.
void set_request(WebRequest *request)
Set associated request.
virtual size_t chunk_size()
Chunksize.
virtual ~WebReply()
Destructor.
WebRequest * get_request() const
Get associated request.
Fawkes library namespace.
DynamicWebReply(Code code)
Constructor.
WebReply(Code code)
Constructor.
std::string _body
Body of the reply.
virtual const std::string & body()
Get body.
Code code() const
Get response code.
StaticWebReply(Code code, std::string body="")
Constructor.
void set_caching(bool caching)
Enable or disable caching for this specific reply.
WebReply * no_caching(WebReply *reply)
Disable caching on a reply.
Base class for exceptions in Fawkes.
static void set_caching_default(bool caching)
Enable or disable caching default for replies.
std::map< std::string, std::string > HeaderMap
Map of headers.
void set_code(Code code)
Set response code.
Web request meta data carrier.
void append_body(const char *format,...)
Append to body.
void add_header(const std::string &header, const std::string &content)
Add a HTTP header.
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.
void pack_caching()
Called just before the reply is sent.