{"thread":{"id":"2153","subject":"[PATCH] Support for HTTP transfer timeouts based on transfer speed","startedAt":"2005-10-19T18:59:59Z","lastAt":"2005-10-19T18:59:59Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10290","messageId":"20051019185959.GA6160@reactrix.com","threadId":"2153","inReplyTo":null,"subject":"[PATCH] Support for HTTP transfer timeouts based on transfer speed","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-10-19T18:59:59Z","receivedAt":"2005-10-19T18:59:59Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Add configuration settings to abort HTTP requests if the transfer rate\ndrops below a threshold for a specified length of time.  Environment\nvariables override config file settings.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\nIt looks as though these curl options have been there since 1999 (before\nversion 6.5), so we shouldn't need to conditionally compile them \nbased on LIBCURL_VERSION_NUM.\n\n\n http-fetch.c |   29 +++++++++++++++++++++++++++++\n 1 files changed, 29 insertions(+), 0 deletions(-)\n\ne624aa205da9861a7d70bffbd22df471c92f1561\ndiff --git a/http-fetch.c b/http-fetch.c\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -100,6 +100,8 @@ static char *ssl_key = NULL;\n static char *ssl_capath = NULL;\n #endif\n static char *ssl_cainfo = NULL;\n+static long curl_low_speed_limit = -1;\n+static long curl_low_speed_time = -1;\n \n struct buffer\n {\n@@ -158,6 +160,17 @@ static int http_options(const char *var,\n \t}\n #endif\n \n+\tif (!strcmp(\"http.lowspeedlimit\", var)) {\n+\t\tif (curl_low_speed_limit == -1)\n+\t\t\tcurl_low_speed_limit = (long)git_config_int(var, value);\n+\t\treturn 0;\n+\t}\n+\tif (!strcmp(\"http.lowspeedtime\", var)) {\n+\t\tif (curl_low_speed_time == -1)\n+\t\t\tcurl_low_speed_time = (long)git_config_int(var, value);\n+\t\treturn 0;\n+\t}\n+\n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value);\n }\n@@ -246,6 +259,13 @@ static CURL* get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);\n \tcurl_easy_setopt(result, CURLOPT_FAILONERROR, 1);\n \n+\tif (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {\n+\t\tcurl_easy_setopt(result, CURLOPT_LOW_SPEED_LIMIT,\n+\t\t\t\t curl_low_speed_limit);\n+\t\tcurl_easy_setopt(result, CURLOPT_LOW_SPEED_TIME,\n+\t\t\t\t curl_low_speed_time);\n+\t}\n+\n \treturn result;\n }\n \n@@ -1177,6 +1197,8 @@ int main(int argc, char **argv)\n \tchar *url;\n \tint arg = 1;\n \tstruct active_request_slot *slot;\n+\tchar *low_speed_limit;\n+\tchar *low_speed_time;\n \n \twhile (arg < argc && argv[arg][0] == '-') {\n \t\tif (argv[arg][1] == 't') {\n@@ -1232,6 +1254,13 @@ int main(int argc, char **argv)\n #endif\n \tssl_cainfo = getenv(\"GIT_SSL_CAINFO\");\n \n+\tlow_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n+\tif (low_speed_limit != NULL)\n+\t\tcurl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n+\tlow_speed_time = getenv(\"GIT_HTTP_LOW_SPEED_TIME\");\n+\tif (low_speed_time != NULL)\n+\t\tcurl_low_speed_time = strtol(low_speed_time, NULL, 10);\n+\n \tgit_config(http_options);\n \n \tif (curl_ssl_verify == -1)\n"}]}