comparison Core/HttpServer/MongooseServer.cpp @ 1363:feaf2840917c

Plugins now receive duplicated GET arguments in their REST callbacks
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2015 15:21:26 +0200
parents 6e7e5ed91c2d
children ad94a3583b07
comparison
equal deleted inserted replaced
1362:bf6db7d2f8b1 1363:feaf2840917c
464 464
465 465
466 static bool ExtractMethod(HttpMethod& method, 466 static bool ExtractMethod(HttpMethod& method,
467 const struct mg_request_info *request, 467 const struct mg_request_info *request,
468 const HttpHandler::Arguments& headers, 468 const HttpHandler::Arguments& headers,
469 const HttpHandler::Arguments& argumentsGET) 469 const HttpHandler::GetArguments& argumentsGET)
470 { 470 {
471 std::string overriden; 471 std::string overriden;
472 472
473 // Check whether some PUT/DELETE faking is done 473 // Check whether some PUT/DELETE faking is done
474 474
482 } 482 }
483 else if (!strcmp(request->request_method, "GET")) 483 else if (!strcmp(request->request_method, "GET"))
484 { 484 {
485 // 2. Faking with Ruby on Rail's approach 485 // 2. Faking with Ruby on Rail's approach
486 // GET /my/resource?_method=delete <=> DELETE /my/resource 486 // GET /my/resource?_method=delete <=> DELETE /my/resource
487 methodOverride = argumentsGET.find("_method"); 487 for (size_t i = 0; i < argumentsGET.size(); i++)
488 if (methodOverride != argumentsGET.end()) 488 {
489 { 489 if (argumentsGET[i].first == "_method")
490 overriden = methodOverride->second; 490 {
491 overriden = argumentsGET[i].second;
492 break;
493 }
491 } 494 }
492 } 495 }
493 496
494 if (overriden.size() > 0) 497 if (overriden.size() > 0)
495 { 498 {
565 headers.insert(std::make_pair(name, request->http_headers[i].value)); 568 headers.insert(std::make_pair(name, request->http_headers[i].value));
566 } 569 }
567 570
568 571
569 // Extract the GET arguments 572 // Extract the GET arguments
570 HttpHandler::Arguments argumentsGET; 573 HttpHandler::GetArguments argumentsGET;
571 if (!strcmp(request->request_method, "GET")) 574 if (!strcmp(request->request_method, "GET"))
572 { 575 {
573 HttpHandler::ParseGetArguments(argumentsGET, request->query_string); 576 HttpHandler::ParseGetArguments(argumentsGET, request->query_string);
574 } 577 }
575 578