diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
| commit | 5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch) | |
| tree | 1a81af141708b826e9c61e8a04019994fcca8298 /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.h | 144 |
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 | |||
| 27 | const mstring http_mime_default="application/octet-stream"; | ||
| 28 | |||
| 29 | const mstring HTTP_V10="HTTP/1.0"; | ||
| 30 | const mstring HTTP_V11="HTTP/1.1"; | ||
| 31 | |||
| 32 | /////////////////////////////////////////////////////////////////// | ||
| 33 | // Request types | ||
| 34 | const mstring HTTP_OPTIONS="OPTIONS"; | ||
| 35 | const mstring HTTP_GET="GET"; | ||
| 36 | const mstring HTTP_HEAD="HEAD"; | ||
| 37 | const mstring HTTP_POST="POST"; | ||
| 38 | const mstring HTTP_PUT="PUT"; | ||
| 39 | const mstring HTTP_DELETE="DELETE"; | ||
| 40 | const mstring HTTP_TRACE="TRACE"; | ||
| 41 | const mstring HTTP_CONNECT="CONNECT"; | ||
| 42 | |||
| 43 | class httpReq : public HTTP { | ||
| 44 | public: | ||
| 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; | ||
| 56 | protected: | ||
| 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 | ||
| 68 | const mstring HTTP_100="100 Continue"; | ||
| 69 | const mstring HTTP_101="101 Switching Protocols"; | ||
| 70 | // Successful 2xx | ||
| 71 | const mstring HTTP_200="200 OK"; | ||
| 72 | const mstring HTTP_201="201 Created"; | ||
| 73 | const mstring HTTP_202="202 Accepted"; | ||
| 74 | const mstring HTTP_203="203 Non-Authoritative Information"; | ||
| 75 | const mstring HTTP_204="204 No Content"; | ||
| 76 | const mstring HTTP_205="205 Reset Content"; | ||
| 77 | const mstring HTTP_206="206 Partial Content"; | ||
| 78 | // Redirection 3xx | ||
| 79 | const mstring HTTP_300="300 Multiple Choices"; | ||
| 80 | const mstring HTTP_301="301 Moved Permanently"; | ||
| 81 | const mstring HTTP_302="302 Found"; | ||
| 82 | const mstring HTTP_303="303 See Other"; | ||
| 83 | const mstring HTTP_304="304 Not Modified"; | ||
| 84 | const mstring HTTP_305="305 Use Proxy"; | ||
| 85 | const mstring HTTP_306="306 (Unused)"; | ||
| 86 | const mstring HTTP_307="307 Temporary Redirect"; | ||
| 87 | // Client Error 4xx | ||
| 88 | const mstring HTTP_400="400 Bad Request"; | ||
| 89 | const mstring HTTP_401="401 Unauthorized"; | ||
| 90 | const mstring HTTP_402="402 Payment Required"; | ||
| 91 | const mstring HTTP_403="403 Forbidden"; | ||
| 92 | const mstring HTTP_404="404 Not Found"; | ||
| 93 | const mstring HTTP_405="405 Method Not Allowed"; | ||
| 94 | const mstring HTTP_406="406 Not Acceptable"; | ||
| 95 | const mstring HTTP_407="407 Proxy Authentication Required"; | ||
| 96 | const mstring HTTP_408="408 Request Timeout"; | ||
| 97 | const mstring HTTP_409="409 Conflict"; | ||
| 98 | const mstring HTTP_410="410 Gone"; | ||
| 99 | const mstring HTTP_411="411 Length Required"; | ||
| 100 | const mstring HTTP_412="412 Precondition Failed"; | ||
| 101 | const mstring HTTP_413="413 Request Entity Too Large"; | ||
| 102 | const mstring HTTP_414="414 Request-URI Too Long"; | ||
| 103 | const mstring HTTP_415="415 Unsupported Media Type"; | ||
| 104 | const mstring HTTP_416="416 Requested Range Not Satisfiable"; | ||
| 105 | const mstring HTTP_417="417 Expectation Failed"; | ||
| 106 | // Server Error 5xx | ||
| 107 | const mstring HTTP_500="500 Internal Server Error"; | ||
| 108 | const mstring HTTP_501="501 Not Implemented"; | ||
| 109 | const mstring HTTP_502="502 Bad Gateway"; | ||
| 110 | const mstring HTTP_503="503 Service Unavailable"; | ||
| 111 | const mstring HTTP_504="504 Gateway Timeout"; | ||
| 112 | const mstring HTTP_505="505 HTTP Version Not Supported"; | ||
| 113 | |||
| 114 | struct 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 | |||
| 122 | class httpResp : public HTTP { | ||
| 123 | public: | ||
| 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; | ||
| 133 | protected: | ||
| 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 | |||
