Преглед на файлове

fix #247: not set http_cb = NUlL intern http_cb

ithewei преди 3 години
родител
ревизия
919015b540
променени са 1 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 7 3
      http/server/HttpHandler.cpp

+ 7 - 3
http/server/HttpHandler.cpp

@@ -75,8 +75,15 @@ void HttpHandler::initRequest() {
     req->http_cb = [this](HttpMessage* msg, http_parser_state state, const char* data, size_t size) {
         if (state == HP_HEADERS_COMPLETE) {
             onHeadersComplete();
+        } else if (state == HP_BODY) {
+            if (api_handler && api_handler->state_handler) {
+                // goto cb;
+            } else {
+                msg->body.append(data, size);
+            }
         }
         if (api_handler && api_handler->state_handler) {
+// cb:
             api_handler->state_handler(getHttpContext(), state, data, size);
         }
     };
@@ -223,9 +230,6 @@ void HttpHandler::onHeadersComplete() {
             }
         };
     } else {
-        // NOTE: not hook http_cb
-        pReq->http_cb = NULL;
-
         if (!proxy && service->proxies.size() != 0) {
             // reverse proxy
             std::string proxy_url = service->GetProxyUrl(pReq->path.c_str());