-rw-r--r-- | src/cgi_gateway.cc | 4 |
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 @@ | |||
6 | 6 | ||
7 | namespace kingate { | 7 | namespace kingate { |
8 | 8 | ||
9 | static string empty_string; | 9 | static string empty_string; |
10 | 10 | ||
11 | cgi_gateway::cgi_gateway(cgi_interface& ci) | 11 | cgi_gateway::cgi_gateway(cgi_interface& ci) |
12 | : iface(ci), b_parsed_content(false) { | 12 | : iface(ci), b_parsed_content(false) { |
13 | // Fetch GET content | 13 | // Fetch GET content |
14 | try { | 14 | try { |
15 | string qs = get_meta("QUERY_STRING"); | 15 | string qs = get_meta("QUERY_STRING"); |
16 | parse_query(qs,get); | 16 | parse_query(qs,get); |
17 | }catch(exception_notfound& enf) { } | 17 | }catch(exception_notfound& enf) { } |
18 | // Fetch POST content | 18 | // Fetch POST content |
19 | if(!strcasecmp(content_type().c_str(),"application/x-www-form-urlencoded")) { | 19 | if(!strcasecmp(content_type().c_str(),"application/x-www-form-urlencoded")) { |
20 | unsigned long cl = content_length(); | 20 | unsigned long cl = content_length(); |
21 | if(cl) { | 21 | if(cl) { |
22 | char * tmp = new char[cl]; | 22 | char * tmp = new char[cl]; |
23 | iface.in().read(tmp,cl); | 23 | iface.in().read(tmp,cl); |
24 | string qs(tmp,cl); | 24 | string qs(tmp,cl); |
25 | delete tmp; | 25 | delete tmp; |
26 | parse_query(qs,post); | 26 | parse_query(qs,post); |
27 | } | 27 | } |
28 | b_parsed_content = true; | 28 | b_parsed_content = true; |
29 | } | 29 | } |
30 | // Parse cookies | ||
31 | try { | ||
32 | cookies.parse_cookies(get_meta("HTTP_COOKIE")); | ||
33 | }catch(exception_notfound& enf) { } | ||
30 | } | 34 | } |
31 | 35 | ||
32 | bool cgi_gateway::has_GET(const string& n) const { | 36 | bool cgi_gateway::has_GET(const string& n) const { |
33 | return get.find(n) != get.end(); | 37 | return get.find(n) != get.end(); |
34 | } | 38 | } |
35 | const string& cgi_gateway::get_GET(const string& n) const { | 39 | const string& cgi_gateway::get_GET(const string& n) const { |
36 | params_t::const_iterator i = get.find(n); | 40 | params_t::const_iterator i = get.find(n); |
37 | if(i==get.end()) | 41 | if(i==get.end()) |
38 | throw exception_notfound(CODEPOINT,"no such parameter"); | 42 | throw exception_notfound(CODEPOINT,"no such parameter"); |
39 | return i->second; | 43 | return i->second; |
40 | } | 44 | } |
41 | bool cgi_gateway::has_POST(const string& n) const { | 45 | bool cgi_gateway::has_POST(const string& n) const { |
42 | return post.find(n) != post.end(); | 46 | return post.find(n) != post.end(); |
43 | } | 47 | } |
44 | const string& cgi_gateway::get_POST(const string& n) const { | 48 | const string& cgi_gateway::get_POST(const string& n) const { |
45 | params_t::const_iterator i = post.find(n); | 49 | params_t::const_iterator i = post.find(n); |
46 | if(i==post.end()) | 50 | if(i==post.end()) |
47 | throw exception_notfound(CODEPOINT,"no such parameter"); | 51 | throw exception_notfound(CODEPOINT,"no such parameter"); |
48 | return i->second; | 52 | return i->second; |
49 | } | 53 | } |
50 | bool cgi_gateway::has_param(const string& n) const { | 54 | bool cgi_gateway::has_param(const string& n) const { |
51 | return has_GET(n) || has_POST(n); | 55 | return has_GET(n) || has_POST(n); |
52 | } | 56 | } |
53 | const string& cgi_gateway::get_param(const string& n) const { | 57 | const string& cgi_gateway::get_param(const string& n) const { |