summaryrefslogtreecommitdiff
path: root/src/serv/request.cc
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
commit5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch)
tree1a81af141708b826e9c61e8a04019994fcca8298 /src/serv/request.cc
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/serv/request.cc')
-rw-r--r--src/serv/request.cc279
1 files changed, 279 insertions, 0 deletions
diff --git a/src/serv/request.cc b/src/serv/request.cc
new file mode 100644
index 0000000..163797f
--- /dev/null
+++ b/src/serv/request.cc
@@ -0,0 +1,279 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <serv/htcd.h>
21
22TOK_IMPL(req_mime_version) { out<<Reqd(env)->req->mime_version; }
23TOK_IMPL(req_cont_type) { out<<Reqd(env)->req->cont_type; }
24TOK_IMPL(req_cont_type_charset) { out<<Reqd(env)->req->cont_type_charset; }
25TOK_IMPL(req_cont_type_name) { out<<Reqd(env)->req->cont_type_name; }
26TOK_IMPL(req_cont_type_boundary) { out<<Reqd(env)->req->cont_type_boundary; }
27TOK_IMPL(req_cont_id) { out<<Reqd(env)->req->cont_id; }
28TOK_IMPL(req_cont_desc) { out<<Reqd(env)->req->cont_desc; }
29TOK_IMPL(req_cont_disp) { out<<Reqd(env)->req->cont_disp; }
30TOK_IMPL(req_cont_disp_name) { out<<Reqd(env)->req->cont_disp_name; }
31TOK_IMPL(req_cont_disp_file) { out<<Reqd(env)->req->cont_disp_file; }
32TOK_IMPL(req_cont_trans_enc) { out<<Reqd(env)->req->cont_trans_enc; }
33TOK_IMPL(req_cont_length) { out<<Reqd(env)->req->cont_length; }
34
35TOK_IMPL(req_cache) { out<<Reqd(env)->req->cache; }
36TOK_IMPL(req_connect) { out<<Reqd(env)->req->connect; }
37TOK_IMPL(req_date) { out<<Reqd(env)->req->date; }
38TOK_IMPL(req_pragma) { out<<Reqd(env)->req->pragma; }
39TOK_IMPL(req_trailer) { out<<Reqd(env)->req->trailer; }
40TOK_IMPL(req_trans_enc) { out<<Reqd(env)->req->trans_enc; }
41TOK_IMPL(req_upgrade) { out<<Reqd(env)->req->upgrade; }
42TOK_IMPL(req_via) { out<<Reqd(env)->req->via; }
43TOK_IMPL(req_warning) { out<<Reqd(env)->req->warning; }
44TOK_IMPL(req_allow) { out<<Reqd(env)->req->allow; }
45TOK_IMPL(req_cont_enc) { out<<Reqd(env)->req->cont_enc; }
46TOK_IMPL(req_cont_lang) { out<<Reqd(env)->req->cont_lang; }
47TOK_IMPL(req_cont_location) { out<<Reqd(env)->req->cont_location; }
48TOK_IMPL(req_cont_md5) { out<<Reqd(env)->req->cont_md5; }
49TOK_IMPL(req_cont_range) { out<<Reqd(env)->req->cont_range; }
50TOK_IMPL(req_expires) { out<<Reqd(env)->req->expires; }
51TOK_IMPL(req_lastmod) { out<<Reqd(env)->req->lastmod; }
52
53TOK_IMPL(req_method) { out<<Reqd(env)->req->method; }
54TOK_IMPL(req_uri) { out<<Reqd(env)->req->uri; }
55TOK_IMPL(req_arg) { out<<Reqd(env)->req->arg; }
56TOK_IMPL(req_version) { out<<Reqd(env)->req->version; }
57TOK_IMPL(req_accept) { out<<Reqd(env)->req->accept; }
58TOK_IMPL(req_accept_charset) { out<<Reqd(env)->req->accept_charset; }
59TOK_IMPL(req_accept_enc) { out<<Reqd(env)->req->accept_enc; }
60TOK_IMPL(req_accept_lang) { out<<Reqd(env)->req->accept_lang; }
61TOK_IMPL(req_accept_range) { out<<Reqd(env)->req->accept_range; }
62TOK_IMPL(req_auth) { out<<Reqd(env)->req->auth; }
63TOK_IMPL(req_expect) { out<<Reqd(env)->req->expect; }
64TOK_IMPL(req_from) { out<<Reqd(env)->req->from; }
65TOK_IMPL(req_host) { out<<Reqd(env)->req->host; }
66TOK_IMPL(req_if_match) { out<<Reqd(env)->req->if_match; }
67TOK_IMPL(req_if_mod) { out<<Reqd(env)->req->if_mod; }
68TOK_IMPL(req_if_none) { out<<Reqd(env)->req->if_none; }
69TOK_IMPL(req_if_range) { out<<Reqd(env)->req->if_range; }
70TOK_IMPL(req_if_unmod) { out<<Reqd(env)->req->if_unmod; }
71TOK_IMPL(req_max_forwards) { out<<Reqd(env)->req->max_forwards; }
72TOK_IMPL(req_proxy) { out<<Reqd(env)->req->proxy; }
73TOK_IMPL(req_range) { out<<Reqd(env)->req->range; }
74TOK_IMPL(req_referer) { out<<Reqd(env)->req->referer; }
75TOK_IMPL(req_te) { out<<Reqd(env)->req->te; }
76TOK_IMPL(req_useragent) { out<<Reqd(env)->req->user_agent; }
77
78///////////////////////////////////////////////////////////////////
79
80TOK_IMPL(resp_cookie) {
81 Reqd(env)->resp.set_cookies.push_back(cookie_t(env[0],env[1],env.parg(2)));
82}
83TOK_IMPL(resp_mime_version) { Reqd(env)->resp.mime_version=env[0]; }
84TOK_IMPL(resp_cont_type) { Reqd(env)->resp.cont_type=env[0]; }
85TOK_IMPL(resp_cont_type_charset) { Reqd(env)->resp.cont_type_charset=env[0]; }
86TOK_IMPL(resp_cont_type_name) { Reqd(env)->resp.cont_type_name=env[0]; }
87TOK_IMPL(resp_cont_type_boundary) { Reqd(env)->resp.cont_type_boundary=env[0]; }
88TOK_IMPL(resp_cont_id) { Reqd(env)->resp.cont_id=env[0]; }
89TOK_IMPL(resp_cont_desc) { Reqd(env)->resp.cont_desc=env[0]; }
90TOK_IMPL(resp_cont_disp) { Reqd(env)->resp.cont_disp=env[0]; }
91TOK_IMPL(resp_cont_disp_name) { Reqd(env)->resp.cont_disp_name=env[0]; }
92TOK_IMPL(resp_cont_disp_file) { Reqd(env)->resp.cont_disp_file=env[0]; }
93TOK_IMPL(resp_cont_trans_enc) { Reqd(env)->resp.cont_trans_enc=env[0]; }
94TOK_IMPL(resp_cont_length) { Reqd(env)->resp.cont_length=env[0]; }
95
96TOK_IMPL(resp_cache) { Reqd(env)->resp.cache=env[0]; }
97TOK_IMPL(resp_connect) { Reqd(env)->resp.connect=env[0]; }
98TOK_IMPL(resp_date) { Reqd(env)->resp.date=env[0]; }
99TOK_IMPL(resp_pragma) { Reqd(env)->resp.pragma=env[0]; }
100TOK_IMPL(resp_trailer) { Reqd(env)->resp.trailer=env[0]; }
101TOK_IMPL(resp_trans_enc) { Reqd(env)->resp.trans_enc=env[0]; }
102TOK_IMPL(resp_upgrade) { Reqd(env)->resp.upgrade=env[0]; }
103TOK_IMPL(resp_via) { Reqd(env)->resp.via=env[0]; }
104TOK_IMPL(resp_warning) { Reqd(env)->resp.warning=env[0]; }
105TOK_IMPL(resp_allow) { Reqd(env)->resp.allow=env[0]; }
106TOK_IMPL(resp_cont_enc) { Reqd(env)->resp.cont_enc=env[0]; }
107TOK_IMPL(resp_cont_lang) { Reqd(env)->resp.cont_lang=env[0]; }
108TOK_IMPL(resp_cont_location) { Reqd(env)->resp.cont_location=env[0]; }
109TOK_IMPL(resp_cont_md5) { Reqd(env)->resp.cont_md5=env[0]; }
110TOK_IMPL(resp_cont_range) { Reqd(env)->resp.cont_range=env[0]; }
111TOK_IMPL(resp_expires) { Reqd(env)->resp.expires=env[0]; }
112TOK_IMPL(resp_lastmod) { Reqd(env)->resp.lastmod=env[0]; }
113
114TOK_IMPL(resp_version) { Reqd(env)->resp.version=env[0]; }
115TOK_IMPL(resp_status) { Reqd(env)->resp.status=env[0]; }
116TOK_IMPL(resp_age) { Reqd(env)->resp.age=env[0]; }
117TOK_IMPL(resp_etag) { Reqd(env)->resp.etag=env[0]; }
118TOK_IMPL(resp_location) { Reqd(env)->resp.location=env[0]; }
119TOK_IMPL(resp_proxy_auth) { Reqd(env)->resp.proxy_authent=env[0]; }
120TOK_IMPL(resp_retry) { Reqd(env)->resp.retry=env[0]; }
121TOK_IMPL(resp_server) { Reqd(env)->resp.server=env[0]; }
122TOK_IMPL(resp_vary) { Reqd(env)->resp.vary=env[0]; }
123TOK_IMPL(resp_auth) { Reqd(env)->resp.authent=env[0]; }
124
125TOK_IMPL(resp_accept) { Reqd(env)->resp.accept=env[0]; }
126TOK_IMPL(resp_accept_charset) { Reqd(env)->resp.accept_charset=env[0]; }
127TOK_IMPL(resp_accept_enc) { Reqd(env)->resp.accept_enc=env[0]; }
128TOK_IMPL(resp_accept_lang) { Reqd(env)->resp.accept_lang=env[0]; }
129TOK_IMPL(resp_accept_range) { Reqd(env)->resp.accept_range=env[0]; }
130
131///////////////////////////////////////////////////////////////////
132
133TOK_IMPL(resp_getstatus) { out<<Reqd(env)->resp.status; }
134
135///////////////////////////////////////////////////////////////////
136
137TOK_IMPL(andarg) { sref s=Reqd(env)->req->arg; if(s.nempty()) out.put('?')<<s; }
138
139///////////////////////////////////////////////////////////////////
140
141const mstring reqhelp="%Request header entry\n";
142const mstring resphelp="%Response header entry; takes one argument\n";
143const mstring respgethelp="%Get response header entry\n";
144const mstring x_tag="x";
145
146void envAddReq(tokmap& T)
147{
148 TOK_ADD(req_mime_version,ms_empty,tok_t::PUBLIC,reqhelp);
149 TOK_ADD(req_cont_type,ms_empty,tok_t::PUBLIC,reqhelp);
150 TOK_ADD(req_cont_type_charset,ms_empty,tok_t::PUBLIC,reqhelp);
151 TOK_ADD(req_cont_type_name,ms_empty,tok_t::PUBLIC,reqhelp);
152 TOK_ADD(req_cont_type_boundary,ms_empty,tok_t::PUBLIC,reqhelp);
153 TOK_ADD(req_cont_id,ms_empty,tok_t::PUBLIC,reqhelp);
154 TOK_ADD(req_cont_desc,ms_empty,tok_t::PUBLIC,reqhelp);
155 TOK_ADD(req_cont_disp,ms_empty,tok_t::PUBLIC,reqhelp);
156 TOK_ADD(req_cont_disp_name,ms_empty,tok_t::PUBLIC,reqhelp);
157 TOK_ADD(req_cont_disp_file,ms_empty,tok_t::PUBLIC,reqhelp);
158 TOK_ADD(req_cont_trans_enc,ms_empty,tok_t::PUBLIC,reqhelp);
159 TOK_ADD(req_cont_length,ms_empty,tok_t::PUBLIC,reqhelp);
160
161 TOK_ADD(req_cache,ms_empty,tok_t::PUBLIC,reqhelp);
162 TOK_ADD(req_connect,ms_empty,tok_t::PUBLIC,reqhelp);
163 TOK_ADD(req_date,ms_empty,tok_t::PUBLIC,reqhelp);
164 TOK_ADD(req_pragma,ms_empty,tok_t::PUBLIC,reqhelp);
165 TOK_ADD(req_trailer,ms_empty,tok_t::PUBLIC,reqhelp);
166 TOK_ADD(req_trans_enc,ms_empty,tok_t::PUBLIC,reqhelp);
167 TOK_ADD(req_upgrade,ms_empty,tok_t::PUBLIC,reqhelp);
168 TOK_ADD(req_via,ms_empty,tok_t::PUBLIC,reqhelp);
169 TOK_ADD(req_warning,ms_empty,tok_t::PUBLIC,reqhelp);
170 TOK_ADD(req_allow,ms_empty,tok_t::PUBLIC,reqhelp);
171 TOK_ADD(req_cont_enc,ms_empty,tok_t::PUBLIC,reqhelp);
172 TOK_ADD(req_cont_lang,ms_empty,tok_t::PUBLIC,reqhelp);
173 TOK_ADD(req_cont_location,ms_empty,tok_t::PUBLIC,reqhelp);
174 TOK_ADD(req_cont_md5,ms_empty,tok_t::PUBLIC,reqhelp);
175 TOK_ADD(req_cont_range,ms_empty,tok_t::PUBLIC,reqhelp);
176 TOK_ADD(req_expires,ms_empty,tok_t::PUBLIC,reqhelp);
177 TOK_ADD(req_lastmod,ms_empty,tok_t::PUBLIC,reqhelp);
178
179 TOK_ADD(req_method,ms_empty,tok_t::PUBLIC,reqhelp);
180 TOK_ADD(req_uri,ms_empty,tok_t::PUBLIC,reqhelp);
181 TOK_ADD(req_arg,ms_empty,tok_t::PUBLIC,reqhelp);
182 TOK_ADD(req_version,ms_empty,tok_t::PUBLIC,reqhelp);
183 TOK_ADD(req_accept,ms_empty,tok_t::PUBLIC,reqhelp);
184 TOK_ADD(req_accept_charset,ms_empty,tok_t::PUBLIC,reqhelp);
185 TOK_ADD(req_accept_enc,ms_empty,tok_t::PUBLIC,reqhelp);
186 TOK_ADD(req_accept_lang,ms_empty,tok_t::PUBLIC,reqhelp);
187 TOK_ADD(req_accept_range,ms_empty,tok_t::PUBLIC,reqhelp);
188 TOK_ADD(req_auth,ms_empty,tok_t::PUBLIC,reqhelp);
189 TOK_ADD(req_expect,ms_empty,tok_t::PUBLIC,reqhelp);
190 TOK_ADD(req_from,ms_empty,tok_t::PUBLIC,reqhelp);
191 TOK_ADD(req_host,ms_empty,tok_t::PUBLIC,reqhelp);
192 TOK_ADD(req_if_match,ms_empty,tok_t::PUBLIC,reqhelp);
193 TOK_ADD(req_if_mod,ms_empty,tok_t::PUBLIC,reqhelp);
194 TOK_ADD(req_if_none,ms_empty,tok_t::PUBLIC,reqhelp);
195 TOK_ADD(req_if_range,ms_empty,tok_t::PUBLIC,reqhelp);
196 TOK_ADD(req_if_unmod,ms_empty,tok_t::PUBLIC,reqhelp);
197 TOK_ADD(req_max_forwards,ms_empty,tok_t::PUBLIC,reqhelp);
198 TOK_ADD(req_proxy,ms_empty,tok_t::PUBLIC,reqhelp);
199 TOK_ADD(req_range,ms_empty,tok_t::PUBLIC,reqhelp);
200 TOK_ADD(req_referer,ms_empty,tok_t::PUBLIC,reqhelp);
201 TOK_ADD(req_te,ms_empty,tok_t::PUBLIC,reqhelp);
202 TOK_ADD(req_useragent,ms_empty,tok_t::PUBLIC,reqhelp);
203
204 ///////////////////////////////////////////////////////////////
205
206 TOK_ADD(andarg,ms_empty,tok_t::PUBLIC,
207 "%Conditional output of argument string\n"
208 "%Syntax: \\andarg\n"
209 "%\n"
210 "%Outputs ?\\req.arg if \\req.arg is non-empty.\n"
211 );
212
213 TOK_ADD(resp_cookie,"xx?",tok_t::SYSONLY,
214 "%Set cookie\n"
215 "%Syntax: \\resp.cookie{name}{val}<options>\n"
216 "%\n"
217 "%Sets the cookie name to value val\n"
218 "%The options field should be on the form expected\n"
219 "%in the HTTP header, for instance\n"
220 "%domain=something; path=/; expires=http-data\n"
221 "%\n"
222 "%No newlines should be added, and remember that ; needs\n"
223 "%to be escaped.\n"
224 );
225
226 ///////////////////////////////////////////////////////////////
227
228 TOK_ADD(resp_mime_version,x_tag,tok_t::SYSONLY,resphelp);
229 TOK_ADD(resp_cont_type,x_tag,tok_t::SYSONLY,resphelp);
230 TOK_ADD(resp_cont_type_charset,x_tag,tok_t::SYSONLY,resphelp);
231 TOK_ADD(resp_cont_type_name,x_tag,tok_t::SYSONLY,resphelp);
232 TOK_ADD(resp_cont_type_boundary,x_tag,tok_t::SYSONLY,resphelp);
233 TOK_ADD(resp_cont_id,x_tag,tok_t::SYSONLY,resphelp);
234 TOK_ADD(resp_cont_desc,x_tag,tok_t::SYSONLY,resphelp);
235 TOK_ADD(resp_cont_disp,x_tag,tok_t::SYSONLY,resphelp);
236 TOK_ADD(resp_cont_disp_name,x_tag,tok_t::SYSONLY,resphelp);
237 TOK_ADD(resp_cont_disp_file,x_tag,tok_t::SYSONLY,resphelp);
238 TOK_ADD(resp_cont_trans_enc,x_tag,tok_t::SYSONLY,resphelp);
239 TOK_ADD(resp_cont_length,x_tag,tok_t::SYSONLY,resphelp);
240
241 TOK_ADD(resp_cache,x_tag,tok_t::SYSONLY,resphelp);
242 TOK_ADD(resp_connect,x_tag,tok_t::SYSONLY,resphelp);
243 TOK_ADD(resp_date,x_tag,tok_t::SYSONLY,resphelp);
244 TOK_ADD(resp_pragma,x_tag,tok_t::SYSONLY,resphelp);
245 TOK_ADD(resp_trailer,x_tag,tok_t::SYSONLY,resphelp);
246 TOK_ADD(resp_trans_enc,x_tag,tok_t::SYSONLY,resphelp);
247 TOK_ADD(resp_upgrade,x_tag,tok_t::SYSONLY,resphelp);
248 TOK_ADD(resp_via,x_tag,tok_t::SYSONLY,resphelp);
249 TOK_ADD(resp_warning,x_tag,tok_t::SYSONLY,resphelp);
250 TOK_ADD(resp_allow,x_tag,tok_t::SYSONLY,resphelp);
251 TOK_ADD(resp_cont_enc,x_tag,tok_t::SYSONLY,resphelp);
252 TOK_ADD(resp_cont_lang,x_tag,tok_t::SYSONLY,resphelp);
253 TOK_ADD(resp_cont_location,x_tag,tok_t::SYSONLY,resphelp);
254 TOK_ADD(resp_cont_md5,x_tag,tok_t::SYSONLY,resphelp);
255 TOK_ADD(resp_cont_range,x_tag,tok_t::SYSONLY,resphelp);
256 TOK_ADD(resp_expires,x_tag,tok_t::SYSONLY,resphelp);
257 TOK_ADD(resp_lastmod,x_tag,tok_t::SYSONLY,resphelp);
258
259 TOK_ADD(resp_version,x_tag,tok_t::SYSONLY,resphelp);
260 TOK_ADD(resp_status,x_tag,tok_t::SYSONLY,resphelp);
261 TOK_ADD(resp_age,x_tag,tok_t::SYSONLY,resphelp);
262 TOK_ADD(resp_etag,x_tag,tok_t::SYSONLY,resphelp);
263 TOK_ADD(resp_location,x_tag,tok_t::SYSONLY,resphelp);
264 TOK_ADD(resp_proxy_auth,x_tag,tok_t::SYSONLY,resphelp);
265 TOK_ADD(resp_retry,x_tag,tok_t::SYSONLY,resphelp);
266 TOK_ADD(resp_server,x_tag,tok_t::SYSONLY,resphelp);
267 TOK_ADD(resp_vary,x_tag,tok_t::SYSONLY,resphelp);
268 TOK_ADD(resp_auth,x_tag,tok_t::SYSONLY,resphelp);
269
270 TOK_ADD(resp_accept,x_tag,tok_t::SYSONLY,resphelp);
271 TOK_ADD(resp_accept_charset,x_tag,tok_t::SYSONLY,resphelp);
272 TOK_ADD(resp_accept_enc,x_tag,tok_t::SYSONLY,resphelp);
273 TOK_ADD(resp_accept_lang,x_tag,tok_t::SYSONLY,resphelp);
274 TOK_ADD(resp_accept_range,x_tag,tok_t::SYSONLY,resphelp);
275
276 ///////////////////////////////////////////////////////////////
277
278 TOK_ADD(resp_getstatus,ms_empty,tok_t::PUBLIC,respgethelp);
279}