tcpkeepalive: add CURLOPT_TCP_KEEPCNT and --keepalive-cnt

Closes #13885
This commit is contained in:
Andy Pan 2024-06-05 11:30:16 +08:00 committed by Daniel Stenberg
parent 02ff5d53a8
commit b77d627d24
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
25 changed files with 210 additions and 20 deletions

View file

@ -249,7 +249,8 @@ struct OperationConfig {
bool post302;
bool post303;
bool nokeepalive; /* for keepalive needs */
long alivetime;
long alivetime; /* keepalive-time */
long alivecnt; /* keepalive-cnt */
bool content_disposition; /* use Content-disposition filename */
int default_node_flags; /* default flags to search for each 'node', which

View file

@ -179,6 +179,7 @@ typedef enum {
C_JSON,
C_JUNK_SESSION_COOKIES,
C_KEEPALIVE,
C_KEEPALIVE_CNT,
C_KEEPALIVE_TIME,
C_KEY,
C_KEY_TYPE,
@ -465,6 +466,7 @@ static const struct LongShort aliases[]= {
{"json", ARG_STRG, ' ', C_JSON},
{"junk-session-cookies", ARG_BOOL, 'j', C_JUNK_SESSION_COOKIES},
{"keepalive", ARG_BOOL, ' ', C_KEEPALIVE},
{"keepalive-cnt", ARG_STRG, ' ', C_KEEPALIVE_CNT},
{"keepalive-time", ARG_STRG, ' ', C_KEEPALIVE_TIME},
{"key", ARG_FILE, ' ', C_KEY},
{"key-type", ARG_STRG, ' ', C_KEY_TYPE},
@ -1826,6 +1828,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case C_KEEPALIVE_TIME: /* --keepalive-time */
err = str2unum(&config->alivetime, nextarg);
break;
case C_KEEPALIVE_CNT: /* --keepalive-cnt */
err = str2unum(&config->alivecnt, nextarg);
break;
case C_POST301: /* --post301 */
config->post301 = toggle;
break;

View file

@ -324,6 +324,9 @@ const struct helptxt helptext[] = {
{"-j, --junk-session-cookies",
"Ignore session cookies read from file",
CURLHELP_HTTP},
{" --keepalive-cnt <integer>",
"Maximum number of keepalive probes",
CURLHELP_CONNECTION},
{" --keepalive-time <seconds>",
"Interval time for keepalive probes",
CURLHELP_CONNECTION},

View file

@ -2111,6 +2111,8 @@ static CURLcode single_transfer(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->alivetime);
my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->alivetime);
}
if(config->alivecnt)
my_setopt(curl, CURLOPT_TCP_KEEPCNT, config->alivecnt);
}
else
my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 0L);