Kaynağa Gözat

fix http2 http_cb

ithewei 3 yıl önce
ebeveyn
işleme
b147d53e32
2 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 5 4
      http/Http2Parser.cpp
  2. 2 0
      http/server/HttpHandler.cpp

+ 5 - 4
http/Http2Parser.cpp

@@ -409,6 +409,9 @@ int on_frame_recv_callback(nghttp2_session *session,
     default:
         break;
     }
+    if (hp->state == H2_RECV_HEADERS && hp->parsed->http_cb) {
+        hp->parsed->http_cb(hp->parsed, HP_HEADERS_COMPLETE, NULL, 0);
+    }
     if (frame->hd.stream_id >= hp->stream_id) {
         hp->stream_id = frame->hd.stream_id;
         hp->stream_closed = 0;
@@ -416,10 +419,8 @@ int on_frame_recv_callback(nghttp2_session *session,
             printd("on_stream_closed stream_id=%d\n", hp->stream_id);
             hp->stream_closed = 1;
             hp->frame_type_when_stream_closed = frame->hd.type;
-            if (hp->parsed->http_cb) {
-                if (hp->state == H2_RECV_HEADERS) {
-                    hp->parsed->http_cb(hp->parsed, HP_HEADERS_COMPLETE, NULL, 0);
-                } else if (hp->state == H2_RECV_DATA) {
+            if (hp->state == H2_RECV_HEADERS || hp->state == H2_RECV_DATA) {
+                if (hp->parsed->http_cb) {
                     hp->parsed->http_cb(hp->parsed, HP_MESSAGE_COMPLETE, NULL, 0);
                 }
             }

+ 2 - 0
http/server/HttpHandler.cpp

@@ -15,6 +15,8 @@ HttpHandler::HttpHandler() {
     protocol = UNKNOWN;
     state = WANT_RECV;
     ssl = false;
+    keepalive = true;
+    proxy = false;
     service = NULL;
     ws_service = NULL;
     api_handler = NULL;