فهرست منبع

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

bel 11 سال پیش
والد
کامیت
49c1633475
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  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
         /* We have returned all buffered data. Read new data from the remote
            socket. */
            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;
     return nread;
 }
 }