@@ -26,285 +26,9 @@ using namespace std;
2626namespace httpserver
2727{
2828// REQUEST
29- inline HttpRequest::HttpRequest ():
30- content(" " )
29+ void HttpRequest::setMethod (const std::string& method)
3130{
32- this ->content = " " ;
33- }
34-
35- HttpRequest::HttpRequest (const HttpRequest& o)
36- {
37- this ->user = o.user ;
38- this ->pass = o.pass ;
39- this ->path = o.path ;
40- this ->method = o.method ;
41- this ->post_path = o.post_path ;
42- this ->headers = o.headers ;
43- this ->args = o.args ;
44- this ->content = o.content ;
45- }
46-
47- inline const string HttpRequest::getUser () const
48- {
49- return this ->user ;
50- }
51-
52- inline const string HttpRequest::getPass () const
53- {
54- return this ->pass ;
55- }
56-
57- inline void HttpRequest::setUser (const std::string& user)
58- {
59- this ->user = user;
60- }
61-
62- inline void HttpRequest::setDigestedUser (const std::string& digestedUser)
63- {
64- this ->digestedUser = digestedUser;
65- }
66-
67- inline const string HttpRequest::getDigestedUser () const
68- {
69- return this ->digestedUser ;
70- }
71-
72- inline void HttpRequest::setPass (const std::string& pass)
73- {
74- this ->pass = pass;
75- }
76-
77- inline const string HttpRequest::getPath () const
78- {
79- return this ->path ;
80- }
81-
82- inline const vector<string> HttpRequest::getPathPieces () const
83- {
84- return this ->post_path ;
85- }
86-
87- inline int HttpRequest::getPathPiecesSize () const
88- {
89- return this ->post_path .size ();
90- }
91-
92- inline const string HttpRequest::getPathPiece (int idx) const
93- {
94- if (((int )(this ->post_path .size ())) > idx)
95- return this ->post_path [idx];
96- return " " ;
97- }
98-
99- inline const string HttpRequest::getMethod () const
100- {
101- return this ->method ;
102- }
103-
104- inline void HttpRequest::setPath (const string& path)
105- {
106- // this->path = boost::to_lower_copy(path);
107- this ->path = path;
108- vector<string> complete_path = HttpUtils::tokenizeUrl (this ->path );
109- for (unsigned int i = 0 ; i < complete_path.size (); i++)
110- {
111- this ->post_path .push_back (complete_path[i]);
112- }
113- }
114-
115- inline void HttpRequest::setMethod (const string& method)
116- {
117- this ->method = string_utilities::to_upper_copy (method);
118- }
119-
120- inline void HttpRequest::setHeader (const string& key, const string& value)
121- {
122- this ->headers [key] = value;
123- }
124-
125- inline void HttpRequest::setFooter (const string& key, const string& value)
126- {
127- this ->footers [key] = value;
128- }
129-
130- inline void HttpRequest::setCookie (const string& key, const string& value)
131- {
132- this ->cookies [key] = value;
133- }
134-
135- inline void HttpRequest::setVersion (const string& version)
136- {
137- this ->version = version;
138- }
139-
140- inline const std::string HttpRequest::getVersion () const
141- {
142- return version;
143- }
144-
145- inline void HttpRequest::setHeaders (const map<string, string>& headers)
146- {
147- map<string, string>::const_iterator it;
148- for (it = headers.begin (); it != headers.end (); it++)
149- this ->headers [it->first ] = it->second ;
150- }
151-
152- inline void HttpRequest::setFooters (const map<string, string>& footers)
153- {
154- map<string, string>::const_iterator it;
155- for (it = footers.begin (); it != footers.end (); it++)
156- this ->footers [it->first ] = it->second ;
157- }
158-
159- inline void HttpRequest::setCookies (const map<string, string>& cookies)
160- {
161- map<string, string>::const_iterator it;
162- for (it = cookies.begin (); it != cookies.end (); it++)
163- this ->cookies [it->first ] = it->second ;
164- }
165-
166- inline void HttpRequest::setArgs (const map<string, string>& args)
167- {
168- map<string, string>::const_iterator it;
169- for (it = args.begin (); it != args.end (); it++)
170- this ->args [it->first ] = it->second ;
171- }
172-
173- inline void HttpRequest::setArg (const string& key, const string& value)
174- {
175- this ->args [key] = value;
176- }
177-
178- inline void HttpRequest::setArg (const char * key, const char * value, size_t size)
179- {
180- this ->args [key] = string (value, size);
181- }
182-
183- inline const string HttpRequest::getArg (const string& key) const
184- {
185- // string new_key = string_utilities::to_lower_copy(key);
186- map<string, string>::const_iterator it = this ->args .find (key);
187- if (it != this ->args .end ())
188- return it->second ;
189- else
190- return " " ;
191- }
192-
193- inline const string HttpRequest::getRequestor () const
194- {
195- return this ->requestor ;
196- }
197-
198- inline void HttpRequest::setRequestor (const std::string& requestor)
199- {
200- this ->requestor = requestor;
201- }
202-
203- inline short HttpRequest::getRequestorPort () const
204- {
205- return this ->requestorPort ;
206- }
207-
208- inline void HttpRequest::setRequestorPort (short requestorPort)
209- {
210- this ->requestorPort = requestorPort;
211- }
212-
213- inline const string HttpRequest::getHeader (const string& key) const
214- {
215- // string new_key = boost::to_lower_copy(key);
216- map<string, string>::const_iterator it = this ->headers .find (key);
217- if (it != this ->headers .end ())
218- return it->second ;
219- else
220- return " " ;
221- }
222-
223- inline const string HttpRequest::getFooter (const string& key) const
224- {
225- // string new_key = boost::to_lower_copy(key);
226- map<string, string>::const_iterator it = this ->footers .find (key);
227- if (it != this ->footers .end ())
228- return it->second ;
229- else
230- return " " ;
231- }
232-
233- inline const std::vector<std::pair<std::string, std::string> > HttpRequest::getHeaders () const
234- {
235- std::vector<std::pair<std::string, std::string> > toRet;
236- map<string, string, HeaderComparator>::const_iterator it;
237- for (it = headers.begin (); it != headers.end (); it++)
238- #ifdef USE_CPP_ZEROX
239- toRet.push_back (make_pair ((*it).first ,(*it).second ));
240- #else
241- toRet.push_back (make_pair<string, string>((*it).first ,(*it).second ));
242- #endif
243- return toRet;
244- }
245-
246- inline const std::vector<std::pair<std::string, std::string> > HttpRequest::getCookies () const
247- {
248- std::vector<std::pair<std::string, std::string> > toRet;
249- map<string, string, HeaderComparator>::const_iterator it;
250- for (it = cookies.begin (); it != cookies.end (); it++)
251- #ifdef USE_CPP_ZEROX
252- toRet.push_back (make_pair ((*it).first ,(*it).second ));
253- #else
254- toRet.push_back (make_pair<string, string>((*it).first ,(*it).second ));
255- #endif
256- return toRet;
257- }
258-
259- inline const std::vector<std::pair<std::string, std::string> > HttpRequest::getFooters () const
260- {
261- std::vector<std::pair<std::string, std::string> > toRet;
262- map<string, string, HeaderComparator>::const_iterator it;
263- for (it = footers.begin (); it != footers.end (); it++)
264- #ifdef USE_CPP_ZEROX
265- toRet.push_back (make_pair ((*it).first ,(*it).second ));
266- #else
267- toRet.push_back (make_pair<string, string>((*it).first ,(*it).second ));
268- #endif
269- return toRet;
270- }
271-
272- inline const std::vector<std::pair<std::string, std::string> > HttpRequest::getArgs () const
273- {
274- std::vector<std::pair<std::string, std::string> > toRet;
275- map<string, string, ArgComparator>::const_iterator it;
276- for (it = args.begin (); it != args.end (); it++)
277- #ifdef USE_CPP_ZEROX
278- toRet.push_back (make_pair ((*it).first ,(*it).second ));
279- #else
280- toRet.push_back (make_pair<string, string>((*it).first ,(*it).second ));
281- #endif
282- return toRet;
283- }
284-
285- inline const string HttpRequest::getContent () const
286- {
287- return this ->content ;
288- }
289-
290- inline void HttpRequest::setContent (const string& content)
291- {
292- this ->content = content;
293- }
294-
295- inline void HttpRequest::growContent (const char * content, size_t size)
296- {
297- this ->content += string (content, size);
298- }
299-
300- inline void HttpRequest::removeHeader (const string& key)
301- {
302- this ->headers .erase (key);
303- }
304-
305- inline void HttpRequest::set_underlying_connection (struct MHD_Connection * conn)
306- {
307- this ->underlying_connection = conn;
31+ this ->method = string_utilities::to_upper_copy (method);
30832}
30933
31034bool HttpRequest::checkDigestAuth (const std::string& realm, const std::string& password, int nonce_timeout, bool & reloadNonce) const
0 commit comments