summaryrefslogtreecommitdiff
path: root/src/http/resp.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/http/resp.cc
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/http/resp.cc')
-rw-r--r--src/http/resp.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/http/resp.cc b/src/http/resp.cc
new file mode 100644
index 0000000..aa7ed7b
--- /dev/null
+++ b/src/http/resp.cc
@@ -0,0 +1,79 @@
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 <http/http.h>
21
22httpResp::httpResp()
23{
24 server="HTCd/1.2 MT (Unix)";
25 version="HTTP/1.1";
26 status=HTTP_200;
27 mime_version.clear();
28 //accept="*/*";
29 //this is non-standard in response headers - now...
30}
31
32int httpResp::Special(sref line)
33{
34 version=First(line);
35 status=Rest(line);
36 return 1;
37}
38
39int httpResp::Handle(const sref& name,
40 const sref& rawval,
41 const sref& val,
42 const rrpile& opts)
43{
44 if(HTTP::Handle(name,rawval,val,opts)) return 1;
45 else if(eqn(name,age_tag)) age=val;
46 else if(eqn(name,etag_tag)) etag=val;
47 else if(eqn(name,location_tag)) location=val;
48 else if(eqn(name,proxy_authent_tag)) proxy_authent=val;
49 else if(eqn(name,retry_tag)) retry=val;
50 else if(eqn(name,server_tag)) server=val;
51 else if(eqn(name,vary_tag)) vary=val;
52 else if(eqn(name,authent_tag)) authent=val;
53 else if(eqn(name,set_cookie_tag)) {
54 for(rrpile::const_iterator p=opts.begin();p!=opts.end();p++)
55 set_cookies.push_back(cookie_t(p->first,p->second));
56 }
57 else return 0;
58 return 1;
59}
60
61void httpResp::putHead(mstream& out) const
62{
63 out<<version<<" "<<status<<CRLF;
64 if(putval(out,age_tag,age)) putend(out);
65 if(putval(out,etag_tag,etag)) putend(out);
66 if(putval(out,location_tag,location)) putend(out);
67 if(putval(out,proxy_authent_tag,proxy_authent)) putend(out);
68 if(putval(out,retry_tag,retry)) putend(out);
69 if(putval(out,server_tag,server)) putend(out);
70 if(putval(out,vary_tag,vary)) putend(out);
71 if(putval(out,authent_tag,authent)) putend(out);
72 HTTP::putHead(out);
73 for(msvec<cookie_t>::const_iterator p=set_cookies.begin();p!=set_cookies.end();p++) {
74 out<<set_cookie_tag<<": ";
75 putopt1(out,p->name,p->val);
76 if(p->options.nempty()) out<<"; "<<p->options;
77 putend(out);
78 }
79}