/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HTTPH #define HTTPH #include /////////////////////////////////////////////////////////////////// const mstring http_mime_default="application/octet-stream"; const mstring HTTP_V10="HTTP/1.0"; const mstring HTTP_V11="HTTP/1.1"; /////////////////////////////////////////////////////////////////// // Request types const mstring HTTP_OPTIONS="OPTIONS"; const mstring HTTP_GET="GET"; const mstring HTTP_HEAD="HEAD"; const mstring HTTP_POST="POST"; const mstring HTTP_PUT="PUT"; const mstring HTTP_DELETE="DELETE"; const mstring HTTP_TRACE="TRACE"; const mstring HTTP_CONNECT="CONNECT"; class httpReq : public HTTP { public: httpReq(); httpReq(const sref& msg) { Init(msg); } mstring method,uri,arg,version; mstring auth,expect,from,host; mstring if_match,if_mod,if_none,if_range,if_unmod; mstring max_forwards,proxy,range; mstring referer,te,user_agent; sspile cookies; void putHead(mstream& out) const; protected: int Special(sref line); int Handle(const sref& name, const sref& rawval, const sref& val, const rrpile& opts); }; /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // Informational 1xx const mstring HTTP_100="100 Continue"; const mstring HTTP_101="101 Switching Protocols"; // Successful 2xx const mstring HTTP_200="200 OK"; const mstring HTTP_201="201 Created"; const mstring HTTP_202="202 Accepted"; const mstring HTTP_203="203 Non-Authoritative Information"; const mstring HTTP_204="204 No Content"; const mstring HTTP_205="205 Reset Content"; const mstring HTTP_206="206 Partial Content"; // Redirection 3xx const mstring HTTP_300="300 Multiple Choices"; const mstring HTTP_301="301 Moved Permanently"; const mstring HTTP_302="302 Found"; const mstring HTTP_303="303 See Other"; const mstring HTTP_304="304 Not Modified"; const mstring HTTP_305="305 Use Proxy"; const mstring HTTP_306="306 (Unused)"; const mstring HTTP_307="307 Temporary Redirect"; // Client Error 4xx const mstring HTTP_400="400 Bad Request"; const mstring HTTP_401="401 Unauthorized"; const mstring HTTP_402="402 Payment Required"; const mstring HTTP_403="403 Forbidden"; const mstring HTTP_404="404 Not Found"; const mstring HTTP_405="405 Method Not Allowed"; const mstring HTTP_406="406 Not Acceptable"; const mstring HTTP_407="407 Proxy Authentication Required"; const mstring HTTP_408="408 Request Timeout"; const mstring HTTP_409="409 Conflict"; const mstring HTTP_410="410 Gone"; const mstring HTTP_411="411 Length Required"; const mstring HTTP_412="412 Precondition Failed"; const mstring HTTP_413="413 Request Entity Too Large"; const mstring HTTP_414="414 Request-URI Too Long"; const mstring HTTP_415="415 Unsupported Media Type"; const mstring HTTP_416="416 Requested Range Not Satisfiable"; const mstring HTTP_417="417 Expectation Failed"; // Server Error 5xx const mstring HTTP_500="500 Internal Server Error"; const mstring HTTP_501="501 Not Implemented"; const mstring HTTP_502="502 Bad Gateway"; const mstring HTTP_503="503 Service Unavailable"; const mstring HTTP_504="504 Gateway Timeout"; const mstring HTTP_505="505 HTTP Version Not Supported"; struct cookie_t { mstring name,val,options; cookie_t() {} cookie_t(const sref& n,const sref& v) : name(n),val(v) {} cookie_t(const sref& n,const sref& v,const sref& o) : name(n),val(v),options(o) {} }; class httpResp : public HTTP { public: httpResp(); httpResp(const sref& msg) { Init(msg); } mstring version,status; mstring age,etag,location; mstring proxy_authent,retry,server,vary,authent; msvec set_cookies; void putHead(mstream& out) const; protected: int Special(sref line); int Handle(const sref& name, const sref& rawval, const sref& val, const rrpile& opts); }; /////////////////////////////////////////////////////////////////// #endif