hewei преди 5 години
родител
ревизия
490dc6d628
променени са 1 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 7 2
      examples/httpd/http_api_test.h

+ 7 - 2
examples/httpd/http_api_test.h

@@ -41,7 +41,12 @@ inline int http_api_hello(HttpRequest* req, HttpResponse* res) {
 }
 
 inline int http_api_query(HttpRequest* req, HttpResponse* res) {
-    res->kv = req->query_params;
+    // scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
+    // ?query => HttpRequest::query_params
+    for (auto& param : req->query_params) {
+        res->Set(param.first.c_str(), param.second);
+    }
+    response_status(res, 0, "Query completed.");
     return 0;
 }
 
@@ -113,7 +118,7 @@ inline int http_api_test(HttpRequest* req, HttpResponse* res) {
 }
 
 inline int http_api_restful(HttpRequest*req, HttpResponse* res) {
-    // RESTful /:field/ => req->query_params
+    // RESTful /:field/ => HttpRequest::query_params
     for (auto& param : req->query_params) {
         res->Set(param.first.c_str(), param.second);
     }