cURL / Mailing Lists / curl-library / Single Mail

curl-library

[patch] add throttle settings to library.

From: Peter Silva <peter_at_bsqt.homeip.net>
Date: Wed, 14 Jun 2006 05:41:34 -0400

This patch creates items in the settings structure of the API to
reflect --limit-rate settings set at the command line. (Nothing is done with
the settings, they are simply made available to the library.)

The API parameters are MAX_SEND_PER_SECOND, and MAX_RECV_PER_SECOND.

diff -cr curl-7.15.3/include/curl/curl.h
curl-7.15.3_rateInLib/include/curl/curl.h
*** curl-7.15.3/include/curl/curl.h Mon Mar 13 19:05:15 2006
--- curl-7.15.3_rateInLib/include/curl/curl.h Tue Jun 13 20:55:08 2006
***************
*** 937,942 ****
--- 937,947 ----
       extracting it with CURLINFO_LASTSOCKET */
    CINIT(CONNECT_ONLY, LONG, 141),

+ /* if the connection proceeds too quickly then need to slow it down */
+ /* limit-rate: maximum number of bytes per second to send or receive */
+ CINIT(MAX_SEND_PER_SECOND, LONG, 142),
+ CINIT(MAX_RECV_PER_SECOND, LONG, 143),
+
    CURLOPT_LASTENTRY /* the last unused */
  } CURLoption;

diff -cr curl-7.15.3/lib/ca-bundle.h curl-7.15.3_rateInLib/lib/ca-bundle.h
*** curl-7.15.3/lib/ca-bundle.h Mon Mar 20 02:50:34 2006
--- curl-7.15.3_rateInLib/lib/ca-bundle.h Wed Jun 14 05:33:57 2006
***************
*** 1 ****
! /* ca bundle path set in here*/
--- 1,2 ----
! /* This file is generated automatically */
! #define CURL_CA_BUNDLE "/usr/local/share/curl/curl-ca-bundle.crt"
diff -cr curl-7.15.3/lib/url.c curl-7.15.3_rateInLib/lib/url.c
*** curl-7.15.3/lib/url.c Tue Mar 7 18:11:42 2006
--- curl-7.15.3_rateInLib/lib/url.c Wed Jun 14 05:19:14 2006
***************
*** 1013,1018 ****
--- 1013,1032 ----
       */
      data->set.low_speed_limit=va_arg(param, long);
      break;
+ case CURLOPT_MAX_SEND_PER_SECOND:
+ /*
+ * The max speed limit that sends transfer more than
+ * CURLOPT_MAX_SEND_PER_SECOND bytes per second the transfer is
throttled..
+ */
+ data->set.max_send_per_second=va_arg(param, long);
+ break;
+ case CURLOPT_MAX_RECV_PER_SECOND:
+ /*
+ * The max speed limit that sends transfer more than
+ * CURLOPT_MAX_RECV_PER_SECOND bytes per second the transfer is
throttled..
+ */
+ data->set.max_recv_per_second=va_arg(param, long);
+ break;
    case CURLOPT_LOW_SPEED_TIME:
      /*
       * The low speed time that if transfers are below the set
diff -cr curl-7.15.3/lib/urldata.h curl-7.15.3_rateInLib/lib/urldata.h
*** curl-7.15.3/lib/urldata.h Tue Mar 7 18:11:42 2006
--- curl-7.15.3_rateInLib/lib/urldata.h Tue Jun 13 20:45:15 2006
***************
*** 993,998 ****
--- 993,1000 ----
    curl_off_t infilesize; /* size of file to upload, -1 means unknown */
    long low_speed_limit; /* bytes/second */
    long low_speed_time; /* number of seconds */
+ long max_send_per_second; /* high speed limit in bytes/second for upload
*/
+ long max_recv_per_second; /* high speed limit in bytes/second for download
*/
    curl_off_t set_resume_from; /* continue [ftp] transfer from here */
    char *cookie; /* HTTP cookie string to send */
    struct curl_slist *headers; /* linked list of extra headers */
diff -cr curl-7.15.3/src/main.c curl-7.15.3_rateInLib/src/main.c
*** curl-7.15.3/src/main.c Mon Mar 13 19:07:21 2006
--- curl-7.15.3_rateInLib/src/main.c Tue Jun 13 20:47:54 2006
***************
*** 3841,3846 ****
--- 3841,3848 ----
          curl_easy_setopt(curl, CURLOPT_FTPPORT, config->ftpport);
          curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT,
config->low_speed_limit);
          curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
config->low_speed_time);
+ curl_easy_setopt(curl, CURLOPT_MAX_SEND_PER_SECOND,
config->sendpersecond);
+ curl_easy_setopt(curl, CURLOPT_MAX_RECV_PER_SECOND,
config->recvpersecond);
          curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE,
                           config->use_resume?config->resume_from:0);
          curl_easy_setopt(curl, CURLOPT_COOKIE, config->cookie);
Received on 2006-06-14