9 #ifndef __libutilxx__sella__server__HTTPRequest_H__
10 #define __libutilxx__sella__server__HTTPRequest_H__
12 #include "../../common.h"
13 #include "ServerException.h"
20 typedef struct magic_set *magic_t;
33 static const std::string ContentTypeDefault;
38 enum Method { None, Options, Get, Head, Post, Put, Delete, Trace, Connect, Patch, Extension };
39 enum AcceptType { HTML, Plain, JSON, JSONP, XML, XHTML_XML, CSV, PNG, GIF, JPEG, Icon, Any, Text_Any, Text, Application_Any, Application, Image_Any, Image, Audio_Any, Audio, Other };
44 void parse(
const std::string &buffer)
throw (ServerException);
45 void appendBody(
const std::string &data)
throw (ServerException);
46 void appendBody(
const std::vector<char> &data)
throw (ServerException);
48 Method getMethod(
bool useOverride =
true)
const throw ();
49 const std::string& getMethodRaw(
bool useOverride =
true)
const throw ();
50 Method getMethodOverride(
void)
const throw ();
51 const std::string& getMethodOverrideRaw(
void)
const throw ();
52 const std::string& getURI(
void)
const throw ();
53 const std::string& getPath(
void)
const throw ();
54 const std::string& getExtension(
void)
const throw ();
55 const std::string& getQuery(
void)
const throw ();
56 const std::string& getVersion(
void)
const throw ();
57 const std::string& getHost(
void)
const throw ();
58 const std::string& getUserAgent(
void)
const throw ();
59 const std::string& getAuthorization(
void)
const throw ();
60 bool getAuthorizationCredentials(std::string &username, std::string &password)
const throw ();
61 const std::vector<std::string>& getAccept(
void)
const throw ();
62 AcceptType getAcceptType(AcceptType fallback = Other)
const throw ();
63 const std::vector<std::string>& getHeaders()
const throw ();
64 std::string getHeader(
const std::string &header)
const throw (ServerException);
65 const std::string getBody(
void)
const throw ();
66 const std::vector<char>& getContent(
void)
const throw ();
68 bool isContinue(
void)
const throw ();
69 bool isChunked(
void)
const throw ();
70 bool isAcceptGzip(
void)
const throw ();
71 bool isAcceptDeflate(
void)
const throw ();
72 bool isBasicAuthorization(
void)
const throw ();
74 bool hasHeader(
const std::string &header)
const throw (ServerException);
76 bool empty(
void)
const throw ();
77 void clear(
void)
throw ();
79 std::string str(
void)
const throw ();
80 void print(
void)
const throw ();
83 std::string getFullpath(
const std::string &file = std::string())
throw (ServerException);
84 std::string getMIMEType(
const std::string &file,
const std::string &fallback = std::string())
const throw (ServerException);
85 std::string getMIMEType(
const std::string &buffer,
size_t size,
const std::string &fallback = std::string())
const throw (ServerException);
87 bool isDirectory(
const std::string &path)
const throw ();
88 bool isFile(
const std::string &file)
const throw ();
90 void magic_open(magic_t &
magic)
const throw (ServerException);
91 void magic_close(magic_t &magic)
const throw ();
96 std::string methodRaw;
97 Method methodOverride;
98 std::string methodOverrideRaw;
101 std::string extension;
104 std::vector<std::string> headers;
107 std::string userAgent;
108 std::vector<std::string> accept;
109 std::vector<std::string> acceptCharset;
110 std::vector<std::string> acceptEncoding;
111 std::vector<std::string> acceptLanguage;
112 std::string transferEncoding;
113 std::string authorization;
114 std::string connection;
115 std::string cacheControl;
117 std::string contentType;
118 unsigned long long contentLength;
120 std::vector<char> content;