Skip to content

Commit 683c4ad

Browse files
author
Sebastiano Merlino
committed
Modified in order to solve path pieces duplication (issue 23)
1 parent 9ea2ca6 commit 683c4ad

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/Webserver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,6 @@ int Webserver::answerToConnection(void* cls, MHD_Connection* connection,
649649
mr->dhr = &supportReq;
650650
}
651651

652-
mr->dhr->setPath(string(st_url));
653-
mr->dhr->setMethod(string(method));
654-
655-
MHD_get_connection_values (connection, MHD_HEADER_KIND, &buildRequestHeader, (void*) mr->dhr);
656-
MHD_get_connection_values (connection, MHD_FOOTER_KIND, &buildRequestFooter, (void*) mr->dhr);
657-
MHD_get_connection_values (connection, MHD_COOKIE_KIND, &buildRequestCookie, (void*) mr->dhr);
658-
659652
if ( 0 == strcmp(method, MHD_HTTP_METHOD_DELETE) ||
660653
0 == strcmp(method, MHD_HTTP_METHOD_GET) ||
661654
0 == strcmp(method, MHD_HTTP_METHOD_HEAD) ||
@@ -688,6 +681,13 @@ int Webserver::answerToConnection(void* cls, MHD_Connection* connection,
688681
return method_not_acceptable_page(cls, connection);
689682
}
690683

684+
MHD_get_connection_values (connection, MHD_HEADER_KIND, &buildRequestHeader, (void*) mr->dhr);
685+
MHD_get_connection_values (connection, MHD_FOOTER_KIND, &buildRequestFooter, (void*) mr->dhr);
686+
MHD_get_connection_values (connection, MHD_COOKIE_KIND, &buildRequestCookie, (void*) mr->dhr);
687+
688+
mr->dhr->setPath(st_url);
689+
mr->dhr->setMethod(method);
690+
691691
if (0 == strcmp (method, MHD_HTTP_METHOD_POST) || 0 == strcmp(method, MHD_HTTP_METHOD_PUT))
692692
{
693693
supportReq = *(mr->dhr);

src/httpserver/HttpResponse.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ class HttpResponse
9999
**/
100100
HttpResponse(const HttpResponse& b):
101101
content(b.content),
102+
responseType(b.responseType),
102103
responseCode(b.responseCode),
103104
headers(b.headers),
104105
footers(b.footers),
105-
responseType(b.responseType),
106106
realm(b.realm),
107107
opaque(b.opaque),
108108
reloadNonce(b.reloadNonce)

src/httpserver/HttpUtils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <gnutls/gnutls.h>
3232
#endif
3333

34-
#define DEFAULT_MASK_VALUE 65535
34+
#define DEFAULT_MASK_VALUE 0xFFFF
3535

3636
namespace httpserver {
3737
namespace http {

test/Test.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ HttpResponse Test::render_POST(const HttpRequest& r)
3434
filestr << r.getContent() << endl;
3535
filestr.close();
3636
cout << "DOPO" << endl;
37+
vector<string> vv = r.getPathPieces();
38+
for(int i = 0; i < vv.size(); i++)
39+
{
40+
cout << vv[i] << endl;
41+
}
3742
return HttpResponse("OK",200);
3843
}
3944

@@ -54,7 +59,7 @@ int main()
5459
Test dt = Test();
5560
Test2 dt2 = Test2();
5661
ws.registerResource(string("base/{var1}/{var2}/drop_test/{var3}/tail"), &dt2, true);
57-
ws.registerResource(string("other"), &dt, true);
62+
ws.registerResource(string("other/side"), &dt, true);
5863
boost::thread* t1 = new boost::thread(boost::bind(&Webserver::start, ws, true));
5964
t1->join();
6065
return 0;

0 commit comments

Comments
 (0)