00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__server__HTTPRequest_H__
00010 #define __libutilxx__sella__server__HTTPRequest_H__
00011
00012 #include "../../common.h"
00013 #include "ServerException.h"
00014
00015 #include <memory>
00016 #include <string>
00017 #include <vector>
00018
00019 namespace sella {
00020 namespace server {
00021 class HTTPRequest;
00022 class HTTP;
00023 class HTTPConnection;
00024 }
00025 }
00026
00027 class sella::server::HTTPRequest {
00028 public:
00029 friend class HTTPConnection;
00030
00031 enum Method { None, Options, Get, Head, Post, Put, Delete, Trace, Connect, Patch, Extension };
00032
00033 HTTPRequest(const HTTP &http) throw ();
00034 virtual ~HTTPRequest() throw ();
00035
00036 void parse(const std::string &buffer) throw (ServerException);
00037 void appendBody(const std::string &data) throw (ServerException);
00038 void appendBody(const std::vector<char> &data) throw (ServerException);
00039
00040 Method getMethod(bool useOverride = true) const throw ();
00041 const std::string& getMethodRaw(bool useOverride = true) const throw ();
00042 Method getMethodOverride(void) const throw ();
00043 const std::string& getMethodOverrideRaw(void) const throw ();
00044 const std::string& getURI(void) const throw ();
00045 const std::string& getPath(void) const throw ();
00046 const std::string& getQuery(void) const throw ();
00047 const std::string& getVersion(void) const throw ();
00048 const std::vector<std::string>& getHeaders() const throw ();
00049 const std::string getBody(void) const throw ();
00050 const std::vector<char>& getContent(void) const throw ();
00051
00052 bool isContinue(void) const throw ();
00053 bool isChunked(void) const throw ();
00054
00055 bool empty(void) const throw ();
00056 void clear(void) throw ();
00057
00058 std::string str(void) const throw ();
00059 void print(void) const throw ();
00060
00061 private:
00062 const HTTP &http;
00063 Method method;
00064 std::string methodRaw;
00065 Method methodOverride;
00066 std::string methodOverrideRaw;
00067 std::string uri;
00068 std::string path;
00069 std::string query;
00070 std::string version;
00071 std::vector<std::string> headers;
00072
00073 std::string host;
00074 std::string userAgent;
00075 std::vector<std::string> accept;
00076 std::vector<std::string> acceptCharset;
00077 std::vector<std::string> acceptEncoding;
00078 std::vector<std::string> acceptLanguage;
00079 std::string transferEncoding;
00080 std::string authorization;
00081 std::string connection;
00082 std::string cacheControl;
00083 std::string expect;
00084 std::string contentType;
00085 unsigned long long contentLength;
00086
00087 std::vector<char> content;
00088 };
00089
00090 #endif
00091
00092
00093
00094