1717 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919*/
20- #include " HttpResource .hpp"
21- #include " HttpUtils .hpp"
22- #include " HttpRequest .hpp"
23- #include " HttpResponse .hpp"
24- #include " Webserver .hpp"
20+ #include " http_resource .hpp"
21+ #include " http_utils .hpp"
22+ #include " http_request .hpp"
23+ #include " http_response .hpp"
24+ #include " webserver .hpp"
2525#include " string_utilities.hpp"
2626
2727using namespace std ;
2828
2929namespace httpserver
3030{
3131// RESOURCE
32- HttpResource::HttpResource ()
33- {
34- this ->allowedMethods [MHD_HTTP_METHOD_GET] = true ;
35- this ->allowedMethods [MHD_HTTP_METHOD_POST] = true ;
36- this ->allowedMethods [MHD_HTTP_METHOD_PUT] = true ;
37- this ->allowedMethods [MHD_HTTP_METHOD_HEAD] = true ;
38- this ->allowedMethods [MHD_HTTP_METHOD_DELETE] = true ;
39- this ->allowedMethods [MHD_HTTP_METHOD_TRACE] = true ;
40- this ->allowedMethods [MHD_HTTP_METHOD_CONNECT] = true ;
41- this ->allowedMethods [MHD_HTTP_METHOD_OPTIONS] = true ;
32+ http_resource::http_resource ()
33+ {
34+ this ->allowed_methods [MHD_HTTP_METHOD_GET] = true ;
35+ this ->allowed_methods [MHD_HTTP_METHOD_POST] = true ;
36+ this ->allowed_methods [MHD_HTTP_METHOD_PUT] = true ;
37+ this ->allowed_methods [MHD_HTTP_METHOD_HEAD] = true ;
38+ this ->allowed_methods [MHD_HTTP_METHOD_DELETE] = true ;
39+ this ->allowed_methods [MHD_HTTP_METHOD_TRACE] = true ;
40+ this ->allowed_methods [MHD_HTTP_METHOD_CONNECT] = true ;
41+ this ->allowed_methods [MHD_HTTP_METHOD_OPTIONS] = true ;
4242}
4343
44- HttpResource ::~HttpResource ()
44+ http_resource ::~http_resource ()
4545{
4646}
4747
48- HttpResponse HttpResource ::render (const HttpRequest & r)
48+ http_response http_resource ::render (const http_request & r)
4949{
50- if (this ->isAllowed (r.getMethod ()))
50+ if (this ->is_allowed (r.get_method ()))
5151 {
5252 return this ->render_404 ();
5353 }
@@ -57,66 +57,66 @@ HttpResponse HttpResource::render(const HttpRequest& r)
5757 }
5858}
5959
60- HttpResponse HttpResource ::render_404 ()
60+ http_response http_resource ::render_404 ()
6161{
62- return HttpStringResponse (NOT_FOUND_ERROR, 404 );
62+ return http_string_response (NOT_FOUND_ERROR, 404 );
6363}
6464
65- HttpResponse HttpResource ::render_405 ()
65+ http_response http_resource ::render_405 ()
6666{
67- return HttpStringResponse (METHOD_ERROR, 405 );
67+ return http_string_response (METHOD_ERROR, 405 );
6868}
6969
70- HttpResponse HttpResource ::render_500 ()
70+ http_response http_resource ::render_500 ()
7171{
72- return HttpStringResponse (GENERIC_ERROR, 500 );
72+ return http_string_response (GENERIC_ERROR, 500 );
7373}
7474
75- HttpResponse HttpResource ::render_GET (const HttpRequest & r)
75+ http_response http_resource ::render_GET (const http_request & r)
7676{
7777 return this ->render (r);
7878}
7979
80- HttpResponse HttpResource ::render_POST (const HttpRequest & r)
80+ http_response http_resource ::render_POST (const http_request & r)
8181{
8282 return this ->render (r);
8383}
8484
85- HttpResponse HttpResource ::render_PUT (const HttpRequest & r)
85+ http_response http_resource ::render_PUT (const http_request & r)
8686{
8787 return this ->render (r);
8888}
8989
90- HttpResponse HttpResource ::render_DELETE (const HttpRequest & r)
90+ http_response http_resource ::render_DELETE (const http_request & r)
9191{
9292 return this ->render (r);
9393}
9494
95- HttpResponse HttpResource ::render_HEAD (const HttpRequest & r)
95+ http_response http_resource ::render_HEAD (const http_request & r)
9696{
9797 return this ->render (r);
9898}
9999
100- HttpResponse HttpResource ::render_TRACE (const HttpRequest & r)
100+ http_response http_resource ::render_TRACE (const http_request & r)
101101{
102102 return this ->render (r);
103103}
104104
105- HttpResponse HttpResource ::render_OPTIONS (const HttpRequest & r)
105+ http_response http_resource ::render_OPTIONS (const http_request & r)
106106{
107107 return this ->render (r);
108108}
109109
110- HttpResponse HttpResource ::render_CONNECT (const HttpRequest & r)
110+ http_response http_resource ::render_CONNECT (const http_request & r)
111111{
112112 return this ->render (r);
113113}
114114
115- HttpResponse HttpResource::routeRequest (const HttpRequest & r)
115+ http_response http_resource::route_request (const http_request & r)
116116{
117- string method = string_utilities::to_upper_copy (r.getMethod ());
117+ string method = string_utilities::to_upper_copy (r.get_method ());
118118
119- HttpResponse res;
119+ http_response res;
120120
121121 if (method == MHD_HTTP_METHOD_GET)
122122 {
0 commit comments