23 #include <webview/reply.h> 25 #include <core/exception.h> 45 bool WebReply::__caching =
true;
57 __headers[
"Cache-Control"] =
"no-cache, no-store, must-revalidate";
58 __headers[
"Pragma"] =
"no-cache";
59 __headers[
"Expires"] =
"0";
99 __headers[header] = content;
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());
227 va_start(args, format);
229 if ( vasprintf(&s, format, args) != -1 ) {
262 std::string::size_type
265 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.
void add_header(std::string header, std::string content)
Add a HTTP header.
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.
static void set_caching(bool caching)
Enable or disable caching for all consecutive replies.
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.