aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnders Bakken <agbakken@gmail.com>2018-01-30 16:33:51 -0800
committerJay Satiro <raysatiro@yahoo.com>2018-02-20 17:51:43 -0500
commit2427d94c6d088b13ad971bb3cee5b7de42b37d24 (patch)
treebbec8183cff0f20d8bd214abdcab5b66f1737669 /src
parent73050fb6ae3c58b6e5d085e8463d94b79dbf2737 (diff)
url: Add option CURLOPT_HAPPY_EYEBALLS_TIMEOUT
- Add new option CURLOPT_HAPPY_EYEBALLS_TIMEOUT to set libcurl's happy eyeball timeout value. - Add new optval macro CURL_HET_DEFAULT to represent the default happy eyeballs timeout value (currently 200 ms). - Add new tool option --happy-eyeballs-timeout-ms to expose CURLOPT_HAPPY_EYEBALLS_TIMEOUT. The -ms suffix is used because the other -timeout options in the tool expect seconds not milliseconds. Closes https://github.com/curl/curl/pull/2260
Diffstat (limited to 'src')
-rw-r--r--src/tool_cfgable.c1
-rw-r--r--src/tool_cfgable.h2
-rw-r--r--src/tool_getparam.c7
-rw-r--r--src/tool_help.c2
-rw-r--r--src/tool_operate.c5
5 files changed, 17 insertions, 0 deletions
diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c
index d77488166..81e16c1c8 100644
--- a/src/tool_cfgable.c
+++ b/src/tool_cfgable.c
@@ -42,6 +42,7 @@ void config_init(struct OperationConfig* config)
config->proto_redir_present = FALSE;
config->proto_default = NULL;
config->tcp_nodelay = TRUE; /* enabled by default */
+ config->happy_eyeballs_timeout_ms = CURL_HET_DEFAULT;
}
static void free_config_fields(struct OperationConfig *config)
diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h
index 0f316775d..743ce725d 100644
--- a/src/tool_cfgable.h
+++ b/src/tool_cfgable.h
@@ -250,6 +250,8 @@ struct OperationConfig {
curl_error synthetic_error; /* if non-zero, it overrides any libcurl
error */
bool ssh_compression; /* enable/disable SSH compression */
+ long happy_eyeballs_timeout_ms; /* happy eyeballs timeout in milliseconds.
+ 0 is valid. default: CURL_HET_DEFAULT. */
struct GlobalConfig *global;
struct OperationConfig *prev;
struct OperationConfig *next; /* Always last in the struct */
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 46e7dd3cd..c6b1a0d6f 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -190,6 +190,7 @@ static const struct LongShort aliases[]= {
{"$X", "tls-max", ARG_STRING},
{"$Y", "suppress-connect-headers", ARG_BOOL},
{"$Z", "compressed-ssh", ARG_BOOL},
+ {"$~", "happy-eyeballs-timeout-ms", ARG_STRING},
{"0", "http1.0", ARG_NONE},
{"01", "http1.1", ARG_NONE},
{"02", "http2", ARG_NONE},
@@ -1111,6 +1112,12 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case 'Z': /* --compressed-ssh */
config->ssh_compression = toggle;
break;
+ case '~': /* --happy-eyeballs-timeout-ms */
+ err = str2unum(&config->happy_eyeballs_timeout_ms, nextarg);
+ if(err)
+ return err;
+ /* 0 is a valid value for this timeout */
+ break;
}
break;
case '#': /* --progress-bar */
diff --git a/src/tool_help.c b/src/tool_help.c
index 751b43aca..9796b7e87 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -160,6 +160,8 @@ static const struct helptxt helptext[] = {
"Put the post data in the URL and use GET"},
{"-g, --globoff",
"Disable URL sequences and ranges using {} and []"},
+ {" --happy-eyeballs-timeout-ms",
+ "How long to wait in milliseconds for IPv6 before trying IPv4"},
{"-I, --head",
"Show document info only"},
{"-H, --header <header/@file>",
diff --git a/src/tool_operate.c b/src/tool_operate.c
index f326a0d0c..c8e9c6901 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1440,6 +1440,11 @@ static CURLcode operate_do(struct GlobalConfig *global,
if(config->tftp_no_options)
my_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
+ /* new in 7.59.0 */
+ if(config->happy_eyeballs_timeout_ms != CURL_HET_DEFAULT)
+ my_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT,
+ config->happy_eyeballs_timeout_ms);
+
/* initialize retry vars for loop below */
retry_sleep_default = (config->retry_delay) ?
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */