Browse Source

fix: http header parsing failures due to TCP packet segmentation (#738)

Zhuo Li 6 months ago
parent
commit
41f679e0c7
1 changed files with 3 additions and 1 deletions
  1. 3 1
      http/Http1Parser.cpp

+ 3 - 1
http/Http1Parser.cpp

@@ -56,7 +56,9 @@ int on_status(http_parser* parser, const char *at, size_t length) {
 int on_header_field(http_parser* parser, const char *at, size_t length) {
     printd("on_header_field:%.*s\n", (int)length, at);
     Http1Parser* hp = (Http1Parser*)parser->data;
-    hp->handle_header();
+    if (hp->state != HP_HEADER_FIELD) {
+        hp->handle_header();
+    }
     hp->state = HP_HEADER_FIELD;
     hp->header_field.append(at, length);
     return 0;