]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
XFERINFOFUNCTION: support CURL_PROGRESSFUNC_CONTINUE
authorJohn Schroeder <john@schroederspace.com>
Tue, 26 Nov 2019 08:13:11 +0000 (09:13 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 26 Nov 2019 08:16:01 +0000 (09:16 +0100)
(also for PROGRESSFUNCTION)

By returning this value from the callback, the internal progress
function call is still called afterward.

Closes #4599

docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3
docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.3
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/progress.c

index b077e3b6ecf02dabe1d84fa48a84fc45aa6e5cf5..4cdb7ec4ba522aaf7775e0b0754f012b6c2f52af 100644 (file)
@@ -60,8 +60,11 @@ Unknown/unused argument values passed to the callback will be set to zero
 the callback will be called one or more times first, before it knows the data
 sizes so a program must be made to handle that.
 
-Returning a non-zero value from this callback will cause libcurl to abort the
-transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
+If your callback function returns CURL_PROGRESSFUNC_CONTINUE it will cause
+libcurl to continue executing the default progress function.
+
+Returning any other non-zero value from this callback will cause libcurl to
+abort the transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
 
 If you transfer data with the multi interface, this function will not be
 called during periods of idleness unless you call the appropriate libcurl
index 9bd89db70cfc4fd2f0b039524c223ca84d81504c..9039aa3982c2ff4bc1c33b6fbc2e52da17598755 100644 (file)
@@ -57,8 +57,11 @@ Unknown/unused argument values passed to the callback will be set to zero
 the callback will be called one or more times first, before it knows the data
 sizes so a program must be made to handle that.
 
-Returning a non-zero value from this callback will cause libcurl to abort the
-transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
+If your callback function returns CURL_PROGRESSFUNC_CONTINUE it will cause
+libcurl to continue executing the default progress function.
+
+Returning any other non-zero value from this callback will cause libcurl to
+abort the transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
 
 If you transfer data with the multi interface, this function will not be
 called during periods of idleness unless you call the appropriate libcurl
index fb37a2dd1c2ba71ce07876bc09be6ec109b85425..29013b148920a77246d056ff67f03d0217a162c6 100644 (file)
@@ -869,6 +869,7 @@ CURL_POLL_INOUT                 7.14.0
 CURL_POLL_NONE                  7.14.0
 CURL_POLL_OUT                   7.14.0
 CURL_POLL_REMOVE                7.14.0
+CURL_PROGRESSFUNC_CONTINUE      7.68.0
 CURL_PROGRESS_BAR               7.1.1         -           7.4.1
 CURL_PROGRESS_STATS             7.1.1         -           7.4.1
 CURL_PUSH_DENY                  7.44.0
index d35174cec5f4e4b2156025a33c400896066772de..a6d5558198fc1419c6f63ed06093f28fcf7b47b1 100644 (file)
@@ -210,6 +210,11 @@ struct curl_httppost {
                                        set. Added in 7.46.0 */
 };
 
+
+/* This is a return code for the progress callback that, when returned, will
+   signal libcurl to continue executing the default progress function */
+#define CURL_PROGRESSFUNC_CONTINUE 0x10000001
+
 /* This is the CURLOPT_PROGRESSFUNCTION callback prototype. It is now
    considered deprecated but was the only choice up until 7.31.0 */
 typedef int (*curl_progress_callback)(void *clientp,
index 2aa9295993114ff90a4288d00dbf5c04302cb841..60a941ab2d7390f3e4f9bec4405a1a6ecbf4f578 100644 (file)
@@ -594,11 +594,13 @@ int Curl_pgrsUpdate(struct connectdata *conn)
                                    data->progress.size_ul,
                                    data->progress.uploaded);
       Curl_set_in_callback(data, false);
-      if(result)
-        failf(data, "Callback aborted");
-      return result;
+      if(result != CURL_PROGRESSFUNC_CONTINUE) {
+        if(result)
+          failf(data, "Callback aborted");
+        return result;
+      }
     }
-    if(data->set.fprogress) {
+    else if(data->set.fprogress) {
       int result;
       /* The older deprecated callback is set, call that */
       Curl_set_in_callback(data, true);
@@ -608,9 +610,11 @@ int Curl_pgrsUpdate(struct connectdata *conn)
                                    (double)data->progress.size_ul,
                                    (double)data->progress.uploaded);
       Curl_set_in_callback(data, false);
-      if(result)
-        failf(data, "Callback aborted");
-      return result;
+      if(result != CURL_PROGRESSFUNC_CONTINUE) {
+        if(result)
+          failf(data, "Callback aborted");
+        return result;
+      }
     }
 
     if(showprogress)