00001 #ifndef WS_REQUEST_H
00002 #define WS_REQUEST_H
00003
00004 #include <string>
00005 #include <map>
00006 #include <vector>
00007
00008 using namespace std;
00009
00010 class wsRequest
00011 {
00012 public:
00013
00014 wsRequest(int socket);
00015
00016 ~wsRequest();
00017
00018 string getParam(const string& param)
00019 {
00020 return myParamVals[param];
00021 }
00022
00023 void output(const string& data);
00024
00025 void output(const char* data, const string& type, int length);
00026
00027 vector<string> getParamList()
00028 {
00029 return myParamList;
00030 }
00031
00032 void setCookie(const string& key, const string& val)
00033 {
00034 myResponseVals["Set-Cookie"] = key + "=" + val;
00035 }
00036
00037 bool isResource()
00038 {
00039 return myResourceFlag;
00040 }
00041
00042 void setResourceFlag(bool flag)
00043 {
00044 myResourceFlag = flag;
00045 }
00046
00047 string getPath()
00048 {
00049 return myPath;
00050 }
00051
00052 private:
00053
00054 void parseQuery(const string& query);
00055
00056 string toLower(const string& s);
00057
00058 string strip(const string& s);
00059
00060 string decode(const string& s);
00061
00062 map<string,string> myHeaderVals;
00063 map<string,string> myParamVals;
00064 map<string,string> myResponseVals;
00065 string myContent;
00066 vector<string> myParamList;
00067 int mySocket;
00068 bool myResourceFlag;
00069 string myPath;
00070 };
00071
00072 #endif
00073