Skip to content

Commit bc41052

Browse files
author
Sebastiano Merlino
committed
Modified in order to follow gnu guidelines for interfaces
1 parent 888350d commit bc41052

23 files changed

+1485
-1470
lines changed

src/HttpUtils.cpp

Lines changed: 0 additions & 427 deletions
This file was deleted.

src/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
INCLUDES = -I../ -I$(srcdir)/httpserver/
2020
METASOURCES = AUTO
2121
lib_LTLIBRARIES = libhttpserver.la
22-
libhttpserver_la_SOURCES = string_utilities.cpp Webserver.cpp HttpUtils.cpp HttpEndpoint.cpp HttpRequest.cpp HttpResponse.cpp HttpResource.cpp
22+
libhttpserver_la_SOURCES = string_utilities.cpp webserver.cpp http_utils.cpp http_endpoint.cpp http_request.cpp http_response.cpp http_resource.cpp
2323
noinst_HEADERS = httpserver/string_utilities.hpp gettext.h
24-
nobase_include_HEADERS = httpserver.hpp httpserver/Webserver.hpp httpserver/HttpUtils.hpp httpserver/HttpEndpoint.hpp httpserver/HttpRequest.hpp httpserver/HttpResponse.hpp httpserver/HttpResource.hpp
24+
nobase_include_HEADERS = httpserver.hpp httpserver/webserver.hpp httpserver/http_utils.hpp httpserver/http_endpoint.hpp httpserver/http_request.hpp httpserver/http_response.hpp httpserver/http_resource.hpp
2525
AM_CXXFLAGS += -fPIC -Wall
2626
libhttpserver_la_LIBADD = -lmicrohttpd
2727
libhttpserver_la_LDFLAGS =

src/autogen_helpers/support_command

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
# License along with this library; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
#
19-
$(srcdir)/WebserverWrap.cpp $(srcdir)/WebserverWrap.h $(swigscripts): $(srcdir)/../httpserver.hpp $(srcdir)/../httpserver/Webserver.hpp $(srcdir)/../httpserver/HttpResponse.hpp $(srcdir)/../httpserver/HttpRequest.hpp $(srcdir)/../httpserver/HttpResource.hpp $(srcdir)/../httpserver/HttpEndpoint.hpp $(srcdir)/../httpserver/HttpUtils.hpp
20-
swig -c++ -$(language) $(swigoptions) -o $(srcdir)/WebserverWrap.cpp -I$(srcdir)/.. -I$(srcdir)/../httpserver $(srcdir)/../httpserver.hpp
19+
$(srcdir)/webserver_wrap.cpp $(srcdir)/webserver_wrap.h $(swigscripts): $(srcdir)/../httpserver.hpp $(srcdir)/../httpserver/webserver.hpp $(srcdir)/../httpserver/http_response.hpp $(srcdir)/../httpserver/http_request.hpp $(srcdir)/../httpserver/http_resource.hpp $(srcdir)/../httpserver/http_endpoint.hpp $(srcdir)/../httpserver/http_utils.hpp
20+
swig -c++ -$(language) $(swigoptions) -o $(srcdir)/webserver_wrap.cpp -I$(srcdir)/.. -I$(srcdir)/../httpserver $(srcdir)/../httpserver.hpp
Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919
*/
20-
#include "HttpEndpoint.hpp"
21-
#include "HttpUtils.hpp"
20+
#include "http_endpoint.hpp"
21+
#include "http_utils.hpp"
2222
#include "string_utilities.hpp"
2323

2424
using namespace std;
@@ -27,13 +27,13 @@ namespace httpserver
2727
{
2828
using namespace http;
2929
//ENDPOINT
30-
HttpEndpoint::HttpEndpoint(const string& url, bool family, bool registration):
30+
http_endpoint::http_endpoint(const string& url, bool family, bool registration):
3131
url_complete(string_utilities::to_lower_copy(url)),
3232
url_modded("/"),
3333
family_url(family),
3434
reg_compiled(false)
3535
{
36-
vector<string> parts = HttpUtils::tokenizeUrl(url);
36+
vector<string> parts = http_utils::tokenize_url(url);
3737
string buffered;
3838
bool first = true;
3939
if(registration)
@@ -118,23 +118,22 @@ HttpEndpoint::HttpEndpoint(const string& url, bool family, bool registration):
118118
this->url_pieces.push_back(parts[i]);
119119
}
120120
}
121-
// this->re_url_modded = boost::xpressive::sregex::compile( url_modded, boost::xpressive::regex_constants::icase );
122121
}
123122

124-
HttpEndpoint::HttpEndpoint(const HttpEndpoint& h)
123+
http_endpoint::http_endpoint(const http_endpoint& h):
124+
url_complete(h.url_complete),
125+
url_modded(h.url_modded),
126+
url_pars(h.url_pars),
127+
url_pieces(h.url_pieces),
128+
chunk_positions(h.chunk_positions),
129+
family_url(h.family_url),
130+
reg_compiled(h.reg_compiled)
125131
{
126-
this->url_complete = h.url_complete;
127-
this->url_modded = h.url_modded;
128-
this->family_url = h.family_url;
129-
this->reg_compiled = h.reg_compiled;
130132
if(this->reg_compiled)
131133
regcomp(&(this->re_url_modded), url_modded.c_str(), REG_EXTENDED|REG_ICASE);
132-
this->url_pars = h.url_pars;
133-
this->url_pieces = h.url_pieces;
134-
this->chunk_positions = h.chunk_positions;
135134
}
136135

137-
HttpEndpoint& HttpEndpoint::operator =(const HttpEndpoint& h)
136+
http_endpoint& http_endpoint::operator =(const http_endpoint& h)
138137
{
139138
this->url_complete = h.url_complete;
140139
this->url_modded = h.url_modded;
@@ -148,12 +147,12 @@ HttpEndpoint& HttpEndpoint::operator =(const HttpEndpoint& h)
148147
return *this;
149148
}
150149

151-
bool HttpEndpoint::operator <(const HttpEndpoint& b) const
150+
bool http_endpoint::operator <(const http_endpoint& b) const
152151
{
153152
return string_utilities::to_lower_copy(this->url_modded) < string_utilities::to_lower_copy(b.url_modded);
154153
}
155154

156-
bool HttpEndpoint::match(const HttpEndpoint& url) const
155+
bool http_endpoint::match(const http_endpoint& url) const
157156
{
158157
if(this->family_url && (url.url_pieces.size() >= this->url_pieces.size()))
159158
{
@@ -172,13 +171,9 @@ bool HttpEndpoint::match(const HttpEndpoint& url) const
172171
}
173172
}
174173
return regexec(&(this->re_url_modded), nn.c_str(), 0, NULL, 0) == 0;
175-
// return boost::xpressive::regex_match(nn, this->re_url_modded);
176174
}
177175
else
178-
{
179176
return regexec(&(this->re_url_modded), url.url_modded.c_str(), 0, NULL, 0) == 0;
180-
// return boost::xpressive::regex_match(url.url_modded, this->re_url_modded);
181-
}
182177
}
183178

184179
};
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919
*/
20-
#include "HttpUtils.hpp"
21-
#include "HttpRequest.hpp"
20+
#include "http_utils.hpp"
21+
#include "http_request.hpp"
2222
#include "string_utilities.hpp"
2323

2424
using namespace std;
2525

2626
namespace httpserver
2727
{
2828
//REQUEST
29-
void HttpRequest::setMethod(const std::string& method)
29+
void http_request::set_method(const std::string& method)
3030
{
3131
this->method = string_utilities::to_upper_copy(method);
3232
}
3333

34-
bool HttpRequest::checkDigestAuth(const std::string& realm, const std::string& password, int nonce_timeout, bool& reloadNonce) const
34+
bool http_request::check_digest_auth(const std::string& realm, const std::string& password, int nonce_timeout, bool& reload_nonce) const
3535
{
36-
int val = MHD_digest_auth_check(underlying_connection, realm.c_str(), digestedUser.c_str(), password.c_str(), nonce_timeout);
36+
int val = MHD_digest_auth_check(underlying_connection, realm.c_str(), digested_user.c_str(), password.c_str(), nonce_timeout);
3737
if(val == MHD_INVALID_NONCE)
3838
{
39-
reloadNonce = true;
39+
reload_nonce = true;
4040
return false;
4141
}
4242
else if(val == MHD_NO)
4343
{
44-
reloadNonce = false;
44+
reload_nonce = false;
4545
return false;
4646
}
47-
reloadNonce = false;
47+
reload_nonce = false;
4848
return true;
4949
}
5050

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@
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

2727
using namespace std;
2828

2929
namespace 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
{
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
1919
*/
2020
#include <cstdio>
21-
#include "HttpUtils.hpp"
22-
#include "Webserver.hpp"
23-
#include "HttpResponse.hpp"
21+
#include "http_utils.hpp"
22+
#include "webserver.hpp"
23+
#include "http_response.hpp"
2424

2525
#include <iostream>
2626

@@ -29,38 +29,38 @@ using namespace std;
2929
namespace httpserver
3030
{
3131
//RESPONSE
32-
HttpFileResponse::HttpFileResponse
32+
http_file_response::http_file_response
3333
(
3434
const string& filename,
35-
int responseCode,
36-
const std::string& contentType
35+
int response_code,
36+
const std::string& content_type
3737
)
3838
{
3939
FILE* f;
4040
this->filename = filename;
4141
if(!(f = fopen(filename.c_str(), "r")))
4242
{
43-
this->responseType = HttpResponse::STRING_CONTENT;
43+
this->response_type = http_response::STRING_CONTENT;
4444
this->content = NOT_FOUND_ERROR;
45-
this->responseCode = HttpUtils::http_not_found;
46-
this->setHeader(HttpUtils::http_header_content_type, contentType);
45+
this->response_code = http_utils::http_not_found;
46+
this->set_header(http_utils::http_header_content_type, content_type);
4747
this->fp = -1;
4848
}
4949
else
5050
{
51-
this->responseType = HttpResponse::FILE_CONTENT;
52-
this->responseCode = responseCode;
51+
this->response_type = http_response::FILE_CONTENT;
52+
this->response_code = response_code;
5353
this->fp = fileno(f);
5454
}
5555
}
5656

57-
ShoutCASTResponse::ShoutCASTResponse
57+
shoutCAST_response::shoutCAST_response
5858
(
5959
const std::string& content,
60-
int responseCode,
61-
const std::string& contentType
60+
int response_code,
61+
const std::string& content_type
6262
):
63-
HttpResponse(HttpResponse::SHOUTCAST_CONTENT, content, responseCode | HttpUtils::shoutcast_response, contentType)
63+
http_response(http_response::SHOUTCAST_CONTENT, content, response_code | http_utils::shoutcast_response, content_type)
6464
{
6565
}
6666

0 commit comments

Comments
 (0)