hewei 6 ani în urmă
părinte
comite
d01215c76f

BIN
html/downloads/libhv-vs-nginx.png


+ 3 - 2
http/server/HttpHandler.cpp

@@ -1,7 +1,6 @@
 #include "HttpHandler.h"
 
 #include "hbase.h"
-#include "hstring.h"
 #include "http_page.h"
 
 int HttpHandler::HandleRequest() {
@@ -105,7 +104,9 @@ make_http_status_page:
             res.headers["Content-Type"] = fc->content_type;
             res.FillContentType();
         }
-        res.headers["Content-Length"] = asprintf("%d", res.content_length);
+        char sz[64];
+        snprintf(sz, sizeof(sz), "%d", res.content_length);
+        res.headers["Content-Length"] = sz;
         res.headers["Last-Modified"] = fc->last_modified;
         res.headers["Etag"] = fc->etag;
     }

+ 1 - 1
scripts/create_repo.sh

@@ -10,4 +10,4 @@ cp src/hv/.gitignore .
 cp src/hv/.clang-format .
 cp src/hv/Makefile .
 cp -r src/hv/etc/* etc
-cp src/hv/main.cpp.tmpl src/main.cpp
+cp src/hv/examples/hmain_test.cpp src/main.cpp

+ 10 - 0
unittest/webbench.c

@@ -293,6 +293,7 @@ connect:
                     ++failed;
                     continue;
                 }
+                int total_rdbytes = 0;
 write:
                 if (timerexpired) break;
                 wrbytes = write(sock, request, len);
@@ -319,7 +320,16 @@ read:
                 if (verbose) {
                     printf("%.*s\n", rdbytes, buf);
                 }
+                static int s_rdbytes = 0;
+                if (s_rdbytes == 0) {
+                    s_rdbytes = rdbytes;
+                }
                 bytes += rdbytes;
+                total_rdbytes += rdbytes;
+                if (total_rdbytes < s_rdbytes) {
+                    // NOTE: some http server head and body send not one packet.
+                    goto read;
+                }
                 ++succeed;
 close:
                 if (!keepalive) {