]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: allow Curl_add_buffer_send() to do a short first send by force
authorDaniel Stenberg <daniel@haxx.se>
Tue, 7 Apr 2020 13:09:04 +0000 (15:09 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 8 Apr 2020 06:12:59 +0000 (08:12 +0200)
In a debug build, settting the environment variable "CURL_SMALLREQSEND"
will make the first HTTP request send not send more bytes than the set
amount, thus ending up verifying that the logic for handling a split
HTTP request send works correctly.

lib/http.c

index bff3adc17010f8d08b492393c8bca561a4d3eff6..e53f0d4824e1cbaa2f7f872e8f4f9d986d7c07b2 100644 (file)
@@ -1229,8 +1229,21 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer **inp,
     memcpy(data->state.ulbuf, ptr, sendsize);
     ptr = data->state.ulbuf;
   }
-  else
+  else {
+#ifdef CURLDEBUG
+    /* Allow debug builds override this logic to force short initial sends */
+    char *p = getenv("CURL_SMALLREQSEND");
+    if(p) {
+      size_t altsize = (size_t)strtoul(p, NULL, 10);
+      if(altsize)
+        sendsize = CURLMIN(size, altsize);
+      else
+        sendsize = size;
+    }
+    else
+#endif
     sendsize = size;
+  }
 
   result = Curl_write(conn, sockfd, ptr, sendsize, &amount);