@@ -60,81 +60,81 @@ const static char* const requestMethodStr[NUM_METHODS] = {
60
60
61
61
// HTTP Response Status codes
62
62
enum Status {
63
- // 1xx Informational
64
- CONTINUE = 100 ,
65
-
66
- // 2xx Success
67
- OK = 200 ,
68
-
69
- // 3xx Redirection
70
-
71
- // 4xx Client Error
72
- BAD_REQUEST = 400 ,
73
- NOT_FOUND = 404 ,
74
-
75
- // 5xx Server Error
76
- SERVER_ERROR = 500 ,
77
- NOT_IMPLEMENTED = 501
63
+ // 1xx Informational
64
+ CONTINUE = 100 ,
65
+
66
+ // 2xx Success
67
+ OK = 200 ,
68
+
69
+ // 3xx Redirection
70
+
71
+ // 4xx Client Error
72
+ BAD_REQUEST = 400 ,
73
+ NOT_FOUND = 404 ,
74
+
75
+ // 5xx Server Error
76
+ SERVER_ERROR = 500 ,
77
+ NOT_IMPLEMENTED = 501
78
78
};
79
79
80
80
class HTTPMessage : public ByteBuffer {
81
81
private:
82
- std::map<std::string, std::string> *headers;
82
+ std::map<std::string, std::string> *headers;
83
83
84
84
protected:
85
85
std::string parseErrorStr;
86
-
86
+
87
87
std::string version;
88
-
88
+
89
89
// Message Body Data (Resource in the case of a response, extra parameters in the case of a request)
90
90
byte* data;
91
91
unsigned int dataLen;
92
92
93
93
protected:
94
- virtual void init ();
95
-
94
+ virtual void init ();
95
+
96
96
public:
97
- HTTPMessage ();
98
- HTTPMessage (std::string sData );
99
- HTTPMessage (byte *pData, unsigned int len);
100
- virtual ~HTTPMessage ();
101
-
97
+ HTTPMessage ();
98
+ HTTPMessage (std::string sData );
99
+ HTTPMessage (byte *pData, unsigned int len);
100
+ virtual ~HTTPMessage ();
101
+
102
102
virtual byte* create () = 0;
103
103
virtual bool parse () = 0;
104
-
105
- // Create helpers
106
- void putLine (std::string str = " " , bool crlf_end= true );
107
- void putHeaders ();
108
-
109
- // Parse helpers
104
+
105
+ // Create helpers
106
+ void putLine (std::string str = " " , bool crlf_end = true );
107
+ void putHeaders ();
108
+
109
+ // Parse helpers
110
110
std::string getLine ();
111
- std::string getStrElement (char delim = 0x20 ); // 0x20 = "space"
112
- void parseHeaders ();
113
- bool parseBody ();
114
-
115
- // Header Map manipulation
111
+ std::string getStrElement (char delim = 0x20 ); // 0x20 = "space"
112
+ void parseHeaders ();
113
+ bool parseBody ();
114
+
115
+ // Header Map manipulation
116
116
void addHeader (std::string line);
117
- void addHeader (std::string key, std::string value);
117
+ void addHeader (std::string key, std::string value);
118
118
void addHeader (std::string key, int value);
119
- std::string getHeaderValue (std::string key);
119
+ std::string getHeaderValue (std::string key);
120
120
std::string getHeaderStr (int index);
121
121
int getNumHeaders ();
122
- void clearHeaders ();
123
-
124
- // Getters & Setters
122
+ void clearHeaders ();
123
+
124
+ // Getters & Setters
125
125
126
126
std::string getParseError () {
127
127
return parseErrorStr;
128
128
}
129
-
130
- void setVersion (std::string v) {
131
- version = v;
132
- }
133
-
134
- std::string getVersion () {
135
- return version;
136
- }
137
-
129
+
130
+ void setVersion (std::string v) {
131
+ version = v;
132
+ }
133
+
134
+ std::string getVersion () {
135
+ return version;
136
+ }
137
+
138
138
void setData (byte* d, unsigned int len) {
139
139
data = d;
140
140
dataLen = len;
0 commit comments