]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: allow debug builds to set buffersize
authorDaniel Stenberg <daniel@haxx.se>
Thu, 16 Feb 2023 08:26:55 +0000 (09:26 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 16 Feb 2023 13:36:24 +0000 (14:36 +0100)
Using the CURL_BUFFERSIZE environment variable.

Closes #10532

src/tool_operate.c

index c9583b850fca11cad0b0877682acf092575fea65..02a5113ddb7ea5e5387f7cd57c6addbf8ac4370e 100644 (file)
@@ -1298,12 +1298,22 @@ static CURLcode single_transfer(struct GlobalConfig *global,
         my_setopt(curl, CURLOPT_SEEKDATA, input);
         my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);
 
-        if(config->recvpersecond &&
-           (config->recvpersecond < BUFFER_SIZE))
-          /* use a smaller sized buffer for better sleeps */
-          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)config->recvpersecond);
+#ifdef CURLDEBUG
+        if(getenv("CURL_BUFFERSIZE")) {
+          long size = strtol(getenv("CURL_BUFFERSIZE"), NULL, 10);
+          if(size)
+            my_setopt(curl, CURLOPT_BUFFERSIZE, size);
+        }
         else
-          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)BUFFER_SIZE);
+#endif
+        {
+          if(config->recvpersecond &&
+             (config->recvpersecond < BUFFER_SIZE))
+            /* use a smaller sized buffer for better sleeps */
+            my_setopt(curl, CURLOPT_BUFFERSIZE, (long)config->recvpersecond);
+          else
+            my_setopt(curl, CURLOPT_BUFFERSIZE, (long)BUFFER_SIZE);
+        }
 
         my_setopt_str(curl, CURLOPT_URL, per->this_url);
         my_setopt(curl, CURLOPT_NOPROGRESS, global->noprogress?1L:0L);