8 #include "http_statuses.h"
9 #include <mxcomp/reflection.h>
10 #include "content_handler.h"
15 typedef std::pair<std::string,std::string> stringpair;
22 Header(
const std::string& name,
const std::string& value);
30 PostContent(
const std::string& name,
const std::string& value);
38 Cookie(
const std::string& name,
const std::string& value,
39 const std::string& Domain =
"",
const std::string& Path =
"",
40 const std::string& Expires =
"",
bool secure =
false,
bool httpOnly =
false);
47 ContentType::t ResponseType;
49 std::vector<Header> headers;
51 std::stringstream response;
56 auto operator <<(
const T& obj) -> decltype( instance_of<std::stringstream>::value << obj, instance_of<Response&>::value)
57 { response << obj;
return *
this;}
59 Response& operator <<(rikitiki::ContentType::t t);
68 template <
typename T1,
typename T2>
69 struct multimap :
public std::multimap<T1, T2> {
70 T2& operator[](
const T1&);
74 typedef std::map<std::string, std::string> QueryStringCollection;
76 typedef std::map<std::string, std::string> CookieCollection;
88 ANY = 0, GET = 1, POST = 2, HEAD = 3, PUT = 4, DELETE = 5, TRACE = 6, OPTIONS = 7, CONNECT = 8, PATCH = 9, OTHER
91 bool mappedPost, mappedQs, mappedHeaders, mappedCookies, mappedPayload, mappedContentType;
93 QueryStringCollection _qs;
95 CookieCollection _cookies;
96 std::multimap<double, ContentType::t>* _accepts;
97 ContentType::t _contentType;
102 virtual void FillAccepts();
103 virtual void FillContentType();
104 virtual void FillPayload() = 0;
105 virtual void FillPost();
107 virtual void FillQueryString() = 0;
108 virtual void FillHeaders() = 0;
109 virtual void FillRequestMethod() = 0;
110 virtual void FillCookies();
113 virtual void writeResponse() = 0;
124 std::multimap<double, ContentType::t>& Accepts();
126 ContentType::t ContentType();
127 QueryStringCollection& QueryString();
129 CookieCollection& Cookies();
130 std::string& Payload();
132 virtual const char* URI() = 0;
134 Method RequestMethod();
136 ConnContext& operator <<(std::function<void(std::ostream&)>);
137 template <
class T>
auto operator <<(
const T& obj) -> decltype( instance_of<Response>::value << obj, (
ConnContext&)*(
ConnContext*)0) ;
144 void mapQueryString(
const char* _qs, QueryStringCollection& qs);
145 ConnContext::Method strToMethod(
const char* method);
148 #include "connContext.tcc"