Browse Source

Fix mg_read for situations where Content-Length was not set and all data is already buffered

bel 11 năm trước cách đây
mục cha
commit
49c1633475
1 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 5 2
      src/civetweb.c

+ 5 - 2
src/civetweb.c

@@ -2299,8 +2299,11 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
 
         /* We have returned all buffered data. Read new data from the remote
            socket. */
-        n = pull_all(NULL, conn, (char *) buf, (int64_t) len);
-        nread = n >= 0 ? nread + n : n;
+        if ((n = pull_all(NULL, conn, (char *) buf, (int64_t) len)) >= 0) {
+            nread += n;
+        } else {
+            nread = (nread > 0 ? nread : n);
+        }
     }
     return nread;
 }