summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--src/cgi_gateway.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cgi_gateway.cc b/src/cgi_gateway.cc
index 1706679..a2681aa 100644
--- a/src/cgi_gateway.cc
+++ b/src/cgi_gateway.cc
@@ -1,64 +1,65 @@
1#include <errno.h> 1#include <errno.h>
2#include <ctype.h> 2#include <ctype.h>
3#include <sstream> 3#include <sstream>
4#include "kingate/cgi_gateway.h" 4#include "kingate/cgi_gateway.h"
5#include "kingate/util.h" 5#include "kingate/util.h"
6#include "kingate/exception.h" 6#include "kingate/exception.h"
7#include "config.h" 7#include "config.h"
8#ifdef HAVE_MIMETIC 8#ifdef HAVE_MIMETIC
9# include <mimetic/mimeentity.h> 9# include <mimetic/mimeentity.h>
10# include <mimetic/parser/itparser.h> 10# include <mimetic/parser/itparser.h>
11#endif /* HAVE_MIMETIC */ 11#endif /* HAVE_MIMETIC */
12 12
13namespace kingate { 13namespace kingate {
14 using mimetic::MimeEntity;
15 14
16#ifdef HAVE_MIMETIC 15#ifdef HAVE_MIMETIC
16 using mimetic::MimeEntity;
17
17 struct TornMimeEntity : public MimeEntity { 18 struct TornMimeEntity : public MimeEntity {
18 typedef istreambuf_iterator<char> it_type; 19 typedef istreambuf_iterator<char> it_type;
19 typedef it_type::iterator_category it_cat; 20 typedef it_type::iterator_category it_cat;
20 struct IParser : public mimetic::IteratorParser<it_type,it_cat> { 21 struct IParser : public mimetic::IteratorParser<it_type,it_cat> {
21 typedef mimetic::IteratorParser<it_type,it_cat> BT; 22 typedef mimetic::IteratorParser<it_type,it_cat> BT;
22 IParser(MimeEntity& me) 23 IParser(MimeEntity& me)
23 : BT::IteratorParser<it_type,it_cat>(me) { } 24 : BT::IteratorParser<it_type,it_cat>(me) { }
24 void loadHeader(it_type bit,it_type eit) { 25 void loadHeader(it_type bit,it_type eit) {
25 m_bit = bit; m_eit = eit; 26 m_bit = bit; m_eit = eit;
26 BT::loadHeader(); 27 BT::loadHeader();
27 } 28 }
28 void loadBody(it_type bit,it_type eit) { 29 void loadBody(it_type bit,it_type eit) {
29 m_bit = bit; m_eit = eit; 30 m_bit = bit; m_eit = eit;
30 BT::loadBody(); 31 BT::loadBody();
31 } 32 }
32 }; 33 };
33 void load(istream& hs,istream& bs,int mask=0) { 34 void load(istream& hs,istream& bs,int mask=0) {
34 IParser prs(*this); 35 IParser prs(*this);
35 prs.iMask(mask); 36 prs.iMask(mask);
36 prs.loadHeader(it_type(hs),it_type()); 37 prs.loadHeader(it_type(hs),it_type());
37 prs.loadBody(it_type(bs),it_type()); 38 prs.loadBody(it_type(bs),it_type());
38 } 39 }
39 }; 40 };
40#endif /* HAVE_MIMETIC */ 41#endif /* HAVE_MIMETIC */
41 42
42 static string empty_string; 43 static string empty_string;
43 44
44 cgi_gateway::basic_file_t::~basic_file_t() { } 45 cgi_gateway::basic_file_t::~basic_file_t() { }
45 46
46 class string_file_t : public cgi_gateway::basic_file_t { 47 class string_file_t : public cgi_gateway::basic_file_t {
47 public: 48 public:
48 string _file_name; 49 string _file_name;
49 string _content_type; 50 string _content_type;
50 stringstream _content; 51 stringstream _content;
51 52
52 string_file_t(const string& fn,const string& ct,const string& s) 53 string_file_t(const string& fn,const string& ct,const string& s)
53 : _file_name(fn), _content_type(ct), _content(s,ios::in) { } 54 : _file_name(fn), _content_type(ct), _content(s,ios::in) { }
54 const string& filename() const { return _file_name; } 55 const string& filename() const { return _file_name; }
55 const string& content_type() const { return _content_type; } 56 const string& content_type() const { return _content_type; }
56 istream& content() { return _content; } 57 istream& content() { return _content; }
57 }; 58 };
58 59
59 cgi_gateway::cgi_gateway(cgi_interface& ci,bool parsebody) 60 cgi_gateway::cgi_gateway(cgi_interface& ci,bool parsebody)
60 : iface(ci), b_parsed_content(false) { 61 : iface(ci), b_parsed_content(false) {
61 // Fetch GET content 62 // Fetch GET content
62 try { 63 try {
63 string qs = get_meta("QUERY_STRING"); 64 string qs = get_meta("QUERY_STRING");
64 parse_query(qs,get); 65 parse_query(qs,get);