summaryrefslogtreecommitdiff
path: root/src/http/http.h
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/http.h
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/http/http.h')
-rw-r--r--src/http/http.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/http/http.h b/src/http/http.h
new file mode 100644
index 0000000..8bd4d23
--- /dev/null
+++ b/src/http/http.h
@@ -0,0 +1,144 @@
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#ifndef HTTPH
21#define HTTPH
22
23#include <http/mime.h>
24
25///////////////////////////////////////////////////////////////////
26
27const mstring http_mime_default="application/octet-stream";
28
29const mstring HTTP_V10="HTTP/1.0";
30const mstring HTTP_V11="HTTP/1.1";
31
32///////////////////////////////////////////////////////////////////
33// Request types
34const mstring HTTP_OPTIONS="OPTIONS";
35const mstring HTTP_GET="GET";
36const mstring HTTP_HEAD="HEAD";
37const mstring HTTP_POST="POST";
38const mstring HTTP_PUT="PUT";
39const mstring HTTP_DELETE="DELETE";
40const mstring HTTP_TRACE="TRACE";
41const mstring HTTP_CONNECT="CONNECT";
42
43class httpReq : public HTTP {
44public:
45 httpReq();
46 httpReq(const sref& msg) { Init(msg); }
47
48 mstring method,uri,arg,version;
49 mstring auth,expect,from,host;
50 mstring if_match,if_mod,if_none,if_range,if_unmod;
51 mstring max_forwards,proxy,range;
52 mstring referer,te,user_agent;
53 sspile cookies;
54
55 void putHead(mstream& out) const;
56protected:
57 int Special(sref line);
58 int Handle(const sref& name,
59 const sref& rawval,
60 const sref& val,
61 const rrpile& opts);
62};
63
64///////////////////////////////////////////////////////////////////
65
66///////////////////////////////////////////////////////////////////
67// Informational 1xx
68const mstring HTTP_100="100 Continue";
69const mstring HTTP_101="101 Switching Protocols";
70// Successful 2xx
71const mstring HTTP_200="200 OK";
72const mstring HTTP_201="201 Created";
73const mstring HTTP_202="202 Accepted";
74const mstring HTTP_203="203 Non-Authoritative Information";
75const mstring HTTP_204="204 No Content";
76const mstring HTTP_205="205 Reset Content";
77const mstring HTTP_206="206 Partial Content";
78// Redirection 3xx
79const mstring HTTP_300="300 Multiple Choices";
80const mstring HTTP_301="301 Moved Permanently";
81const mstring HTTP_302="302 Found";
82const mstring HTTP_303="303 See Other";
83const mstring HTTP_304="304 Not Modified";
84const mstring HTTP_305="305 Use Proxy";
85const mstring HTTP_306="306 (Unused)";
86const mstring HTTP_307="307 Temporary Redirect";
87// Client Error 4xx
88const mstring HTTP_400="400 Bad Request";
89const mstring HTTP_401="401 Unauthorized";
90const mstring HTTP_402="402 Payment Required";
91const mstring HTTP_403="403 Forbidden";
92const mstring HTTP_404="404 Not Found";
93const mstring HTTP_405="405 Method Not Allowed";
94const mstring HTTP_406="406 Not Acceptable";
95const mstring HTTP_407="407 Proxy Authentication Required";
96const mstring HTTP_408="408 Request Timeout";
97const mstring HTTP_409="409 Conflict";
98const mstring HTTP_410="410 Gone";
99const mstring HTTP_411="411 Length Required";
100const mstring HTTP_412="412 Precondition Failed";
101const mstring HTTP_413="413 Request Entity Too Large";
102const mstring HTTP_414="414 Request-URI Too Long";
103const mstring HTTP_415="415 Unsupported Media Type";
104const mstring HTTP_416="416 Requested Range Not Satisfiable";
105const mstring HTTP_417="417 Expectation Failed";
106// Server Error 5xx
107const mstring HTTP_500="500 Internal Server Error";
108const mstring HTTP_501="501 Not Implemented";
109const mstring HTTP_502="502 Bad Gateway";
110const mstring HTTP_503="503 Service Unavailable";
111const mstring HTTP_504="504 Gateway Timeout";
112const mstring HTTP_505="505 HTTP Version Not Supported";
113
114struct cookie_t {
115 mstring name,val,options;
116 cookie_t() {}
117 cookie_t(const sref& n,const sref& v) : name(n),val(v) {}
118 cookie_t(const sref& n,const sref& v,const sref& o) :
119 name(n),val(v),options(o) {}
120};
121
122class httpResp : public HTTP {
123public:
124 httpResp();
125 httpResp(const sref& msg) { Init(msg); }
126
127 mstring version,status;
128 mstring age,etag,location;
129 mstring proxy_authent,retry,server,vary,authent;
130 msvec<cookie_t> set_cookies;
131
132 void putHead(mstream& out) const;
133protected:
134 int Special(sref line);
135 int Handle(const sref& name,
136 const sref& rawval,
137 const sref& val,
138 const rrpile& opts);
139};
140
141///////////////////////////////////////////////////////////////////
142
143#endif
144