summaryrefslogtreecommitdiffabout
path: root/src/cgi_gateway.cc
Side-by-side diff
Diffstat (limited to 'src/cgi_gateway.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/cgi_gateway.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cgi_gateway.cc b/src/cgi_gateway.cc
index 30410f2..ab48f78 100644
--- a/src/cgi_gateway.cc
+++ b/src/cgi_gateway.cc
@@ -6,48 +6,52 @@
namespace kingate {
static string empty_string;
cgi_gateway::cgi_gateway(cgi_interface& ci)
: iface(ci), b_parsed_content(false) {
// Fetch GET content
try {
string qs = get_meta("QUERY_STRING");
parse_query(qs,get);
}catch(exception_notfound& enf) { }
// Fetch POST content
if(!strcasecmp(content_type().c_str(),"application/x-www-form-urlencoded")) {
unsigned long cl = content_length();
if(cl) {
char * tmp = new char[cl];
iface.in().read(tmp,cl);
string qs(tmp,cl);
delete tmp;
parse_query(qs,post);
}
b_parsed_content = true;
}
+ // Parse cookies
+ try {
+ cookies.parse_cookies(get_meta("HTTP_COOKIE"));
+ }catch(exception_notfound& enf) { }
}
bool cgi_gateway::has_GET(const string& n) const {
return get.find(n) != get.end();
}
const string& cgi_gateway::get_GET(const string& n) const {
params_t::const_iterator i = get.find(n);
if(i==get.end())
throw exception_notfound(CODEPOINT,"no such parameter");
return i->second;
}
bool cgi_gateway::has_POST(const string& n) const {
return post.find(n) != post.end();
}
const string& cgi_gateway::get_POST(const string& n) const {
params_t::const_iterator i = post.find(n);
if(i==post.end())
throw exception_notfound(CODEPOINT,"no such parameter");
return i->second;
}
bool cgi_gateway::has_param(const string& n) const {
return has_GET(n) || has_POST(n);
}
const string& cgi_gateway::get_param(const string& n) const {