@@ -567,9 +567,10 @@ void webserver::register_resource(
567567 if (method_not_acceptable_resource)
568568 hrm.method_not_acceptable_resource = method_not_acceptable_resource;
569569
570- registered_resources[
571- details::http_endpoint (resource, family, true , regex_checking)
572- ] = hrm;
570+ details::http_endpoint idx (resource, family, true , regex_checking);
571+
572+ registered_resources[idx] = hrm;
573+ registered_resources_str[idx.url_complete ] = ®istered_resources[idx];
573574}
574575
575576void webserver::schedule_fd (int fd, fd_set* schedule_list, int * max)
@@ -1033,7 +1034,9 @@ bool webserver::stop()
10331034
10341035void webserver::unregister_resource (const string& resource)
10351036{
1036- this ->registered_resources .erase (details::http_endpoint (resource));
1037+ details::http_endpoint he (resource);
1038+ this ->registered_resources .erase (he);
1039+ this ->registered_resources .erase (he.url_complete );
10371040}
10381041
10391042void webserver::ban_ip (const string& ip)
@@ -1433,20 +1436,28 @@ int webserver::finalize_answer(
14331436 int to_ret = MHD_NO;
14341437 http_response* dhrs = 0x0 ;
14351438
1436- map<
1437- details::http_endpoint, details::http_resource_mirror
1438- >::iterator found_endpoint ;
1439+ map<string, details::http_resource_mirror*>::iterator fe;
1440+
1441+ details::http_resource_mirror* hrm ;
14391442
14401443 bool found = false ;
14411444 struct MHD_Response * raw_response;
14421445 if (!single_resource)
14431446 {
1444- details::http_endpoint endpoint (st_url, false , false , regex_checking);
1445- found_endpoint = registered_resources.find (endpoint);
1446- if (found_endpoint == registered_resources.end ())
1447+ fe = registered_resources_str.find (st_url);
1448+ if (fe == registered_resources_str.end ())
14471449 {
14481450 if (regex_checking)
14491451 {
1452+
1453+ map<
1454+ details::http_endpoint, details::http_resource_mirror
1455+ >::iterator found_endpoint;
1456+
1457+ details::http_endpoint endpoint (
1458+ st_url, false , false , regex_checking
1459+ );
1460+
14501461 map<
14511462 details::http_endpoint,
14521463 details::http_resource_mirror
@@ -1495,31 +1506,30 @@ int webserver::finalize_answer(
14951506 {
14961507 mr->dhr ->set_arg (url_pars[i], url_pieces[chunkes[i]]);
14971508 }
1509+
1510+ hrm = &found_endpoint->second ;
14981511 }
14991512 }
15001513 }
15011514 else
1515+ {
1516+ hrm = fe->second ;
15021517 found = true ;
1518+ }
15031519 }
15041520 else
15051521 {
1506- found_endpoint = registered_resources.begin ();
1522+ hrm = & registered_resources.begin ()-> second ;
15071523 found = true ;
15081524 }
15091525 mr->dhr ->set_underlying_connection (connection);
1510- #ifdef DEBUG
1511- if (found)
1512- cout << " Using: " << found_endpoint->first .get_url_complete () << endl;
1513- else
1514- cout << " Endpoint not found!" << endl;
1515- #endif // DEBUG
15161526
15171527 if (found)
15181528 {
15191529 try
15201530 {
1521- if (found_endpoint-> second . is_allowed (method))
1522- ((found_endpoint-> second ). *(mr->callback ))(*mr->dhr , &dhrs);
1531+ if (hrm-> is_allowed (method))
1532+ ((hrm)-> *(mr->callback ))(*mr->dhr , &dhrs);
15231533 else
15241534 {
15251535 method_not_allowed_page (&dhrs, mr);
0 commit comments