author | Michael Krelin <hacker@klever.net> | 2005-07-04 22:54:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-07-04 22:54:09 (UTC) |
commit | c5d7daf77e265b53951e1e2b09c51e2fba5e93dc (patch) (unidiff) | |
tree | 2337ff96d85d8de6d25fbaed75eb9c0d71a1625d /include | |
parent | c8bcbfb951eec5fe14dac0b14f4faaf4a9f9f229 (diff) | |
download | kingate-c5d7daf77e265b53951e1e2b09c51e2fba5e93dc.zip kingate-c5d7daf77e265b53951e1e2b09c51e2fba5e93dc.tar.gz kingate-c5d7daf77e265b53951e1e2b09c51e2fba5e93dc.tar.bz2 |
1. awkward yet working support for POST file upload (requires mimetic)
2. support for NOT handling/parsing POSTed data (including application/x-www-form-urlencoded)
-rw-r--r-- | include/kingate/cgi_gateway.h | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/include/kingate/cgi_gateway.h b/include/kingate/cgi_gateway.h index f20d72b..a26b0ae 100644 --- a/include/kingate/cgi_gateway.h +++ b/include/kingate/cgi_gateway.h | |||
@@ -42,8 +42,39 @@ namespace kingate { | |||
42 | * The POST-passed parameters. | 42 | * The POST-passed parameters. |
43 | */ | 43 | */ |
44 | params_t post; | 44 | params_t post; |
45 | /** | 45 | /** |
46 | * Abstract base class for retrieving posted files. | ||
47 | */ | ||
48 | class basic_file_t { | ||
49 | public: | ||
50 | /** | ||
51 | * Retrieve file name. | ||
52 | * @return filename | ||
53 | */ | ||
54 | virtual const string& filename() const = 0; | ||
55 | /** | ||
56 | * Retrieve file content type. | ||
57 | * @return content type | ||
58 | */ | ||
59 | virtual const string& content_type() const = 0; | ||
60 | /** | ||
61 | * Retrieve file contents. | ||
62 | * @return reference to the stream for accessing file content. | ||
63 | */ | ||
64 | virtual istream& content() = 0; | ||
65 | virtual ~basic_file_t(); | ||
66 | }; | ||
67 | typedef basic_file_t *file_t; | ||
68 | /** | ||
69 | * The map holding information pertaining to files uploaded via post. | ||
70 | */ | ||
71 | typedef multimap<string,file_t> files_t; | ||
72 | /** | ||
73 | * Files uploaded via post | ||
74 | */ | ||
75 | files_t files; | ||
76 | /** | ||
46 | * Cookies passed. | 77 | * Cookies passed. |
47 | */ | 78 | */ |
48 | cookies_t cookies; | 79 | cookies_t cookies; |
49 | /** | 80 | /** |
@@ -53,9 +84,15 @@ namespace kingate { | |||
53 | 84 | ||
54 | /** | 85 | /** |
55 | * @param ci the interface to use. | 86 | * @param ci the interface to use. |
56 | */ | 87 | */ |
57 | cgi_gateway(cgi_interface& ci); | 88 | cgi_gateway(cgi_interface& ci,bool parsebody = true); |
89 | virtual ~cgi_gateway() throw(); | ||
90 | |||
91 | /** | ||
92 | * Parse request body. | ||
93 | */ | ||
94 | void parse_request_body(); | ||
58 | 95 | ||
59 | /** | 96 | /** |
60 | * Check whether there is an 'environment' meta-variable with specific name | 97 | * Check whether there is an 'environment' meta-variable with specific name |
61 | * passed to CGI. | 98 | * passed to CGI. |
@@ -135,12 +172,26 @@ namespace kingate { | |||
135 | /** | 172 | /** |
136 | * Retrieve the parameter passed either via POST or GET | 173 | * Retrieve the parameter passed either via POST or GET |
137 | * (GET-parameter takes precedence). | 174 | * (GET-parameter takes precedence). |
138 | * @param n the parameter name. | 175 | * @param n the parameter name. |
139 | * @return true if yes. | 176 | * @return the parameter contents. |
140 | * @see exception_notfound. | 177 | * @see exception_notfound. |
141 | */ | 178 | */ |
142 | const string& get_param(const string& n) const; | 179 | const string& get_param(const string& n) const; |
180 | /** | ||
181 | * Check to see whether the file was uploaded in the request body. | ||
182 | * @param n the parameter name. | ||
183 | * @return true if yes. | ||
184 | */ | ||
185 | bool has_file(const string& n) const; | ||
186 | /** | ||
187 | * Retrieve the file uploaded in the request body. | ||
188 | * @param n the parameter name. | ||
189 | * @return the file. | ||
190 | * @see exception_notfound. | ||
191 | */ | ||
192 | const file_t get_file(const string& n) const; | ||
193 | file_t get_file(const string& n); | ||
143 | 194 | ||
144 | /** | 195 | /** |
145 | * Retrieve the POST content-type (as passed via CONTENT_TYPE | 196 | * Retrieve the POST content-type (as passed via CONTENT_TYPE |
146 | * environment variable). | 197 | * environment variable). |
@@ -176,9 +227,9 @@ namespace kingate { | |||
176 | /** | 227 | /** |
177 | * Retrieve the CONTENT_LENGTH meta-variable (see RFC3875) | 228 | * Retrieve the CONTENT_LENGTH meta-variable (see RFC3875) |
178 | * @return size of the request message body. | 229 | * @return size of the request message body. |
179 | */ | 230 | */ |
180 | unsigned long cgi_gateway::content_length() const; | 231 | unsigned long content_length() const; |
181 | /** | 232 | /** |
182 | * Retrieve the CONTENT_TYPE meta-variable (see RFC3875) | 233 | * Retrieve the CONTENT_TYPE meta-variable (see RFC3875) |
183 | * @return media type of the request message body. | 234 | * @return media type of the request message body. |
184 | */ | 235 | */ |