Bläddra i källkod

Fix issue #12: Handle post requests with Content-length 0 bytes

bel 11 år sedan
förälder
incheckning
8683723244
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      src/civetweb.c

+ 2 - 2
src/civetweb.c

@@ -2163,8 +2163,8 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
     int64_t n, buffered_len, nread;
     int64_t n, buffered_len, nread;
     const char *body;
     const char *body;
 
 
-    /* If Content-Length is not set, read until socket is closed */
-    if (conn->consumed_content == 0 && conn->content_len == 0) {
+    /* If Content-Length is not set for a PUT or POST request, read until socket is closed */
+    if (conn->consumed_content == 0 && conn->content_len == -1) {
         conn->content_len = INT64_MAX;
         conn->content_len = INT64_MAX;
         conn->must_close = 1;
         conn->must_close = 1;
     }
     }