summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-07 15:09:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-08 08:12:59 +0200
commit3e376059bbc6e5e56013c383f3ae3eef6c3ae8bb (patch)
treead3bb036aa614b7028f32837a9fb7381dd86b114 /lib
parent0bcf975c386ad6285c3ee6b98d3fc4a8f46bdd15 (diff)
downloadcurl-3e376059bbc6e5e56013c383f3ae3eef6c3ae8bb.tar.gz
http: allow Curl_add_buffer_send() to do a short first send by force
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/http.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/http.c b/lib/http.c
index bff3adc17..e53f0d482 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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);