diff options
author | Daniel Stenberg <daniel@haxx.se> | 2023-01-09 15:00:34 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-01-12 16:18:05 +0100 |
commit | 13991d60eeef7d1c6a7ac1e15a45c5210aa2a15d (patch) | |
tree | 0a35423db7a56c28b6b97ee7e0fcbd5f5ba468a2 /src | |
parent | a56d2b0b94d2f6583ac0fd7605e4e4d1644c2ba9 (diff) | |
download | curl-13991d60eeef7d1c6a7ac1e15a45c5210aa2a15d.tar.gz |
src: add --http3-only
Warning: --http3 and --http3-only are subject to change again (or be
removed) before HTTP/3 support goes non-experimental.
Closes #10264
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_getparam.c | 29 | ||||
-rw-r--r-- | src/tool_listhelp.c | 3 | ||||
-rw-r--r-- | src/tool_setopt.c | 1 |
3 files changed, 27 insertions, 6 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c index bb4303a8c..cecaf4b8d 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -208,6 +208,7 @@ static const struct LongShort aliases[]= { {"02", "http2", ARG_NONE}, {"03", "http2-prior-knowledge", ARG_NONE}, {"04", "http3", ARG_NONE}, + {"05", "http3-only", ARG_NONE}, {"09", "http0.9", ARG_BOOL}, {"1", "tlsv1", ARG_NONE}, {"10", "tlsv1.0", ARG_NONE}, @@ -657,6 +658,16 @@ static ParameterError data_urlencode(struct GlobalConfig *global, return PARAM_OK; } +static void sethttpver(struct GlobalConfig *global, + struct OperationConfig *config, + long httpversion) +{ + if(config->httpversion && + (config->httpversion != httpversion)) + warnf(global, "Overrides previous HTTP version option\n"); + + config->httpversion = httpversion; +} ParameterError getparameter(const char *flag, /* f or -long-flag */ char *nextarg, /* NULL if unset */ @@ -1418,25 +1429,31 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ switch(subletter) { case '\0': /* HTTP version 1.0 */ - config->httpversion = CURL_HTTP_VERSION_1_0; + sethttpver(global, config, CURL_HTTP_VERSION_1_0); break; case '1': /* HTTP version 1.1 */ - config->httpversion = CURL_HTTP_VERSION_1_1; + sethttpver(global, config, CURL_HTTP_VERSION_1_1); break; case '2': /* HTTP version 2.0 */ - config->httpversion = CURL_HTTP_VERSION_2_0; + sethttpver(global, config, CURL_HTTP_VERSION_2_0); break; case '3': /* --http2-prior-knowledge */ /* HTTP version 2.0 over clean TCP */ - config->httpversion = CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE; + sethttpver(global, config, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); break; case '4': /* --http3 */ - /* HTTP version 3 go over QUIC - at once */ + /* Try HTTP/3, allow fallback */ + if(!feature_http3) + return PARAM_LIBCURL_DOESNT_SUPPORT; + sethttpver(global, config, CURL_HTTP_VERSION_3); + break; + case '5': /* --http3-only */ + /* Try HTTP/3 without fallback */ if(!feature_http3) return PARAM_LIBCURL_DOESNT_SUPPORT; - config->httpversion = CURL_HTTP_VERSION_3; + sethttpver(global, config, CURL_HTTP_VERSION_3ONLY); break; case '9': /* Allow HTTP/0.9 responses! */ diff --git a/src/tool_listhelp.c b/src/tool_listhelp.c index 505f3bb15..7611cf6a0 100644 --- a/src/tool_listhelp.c +++ b/src/tool_listhelp.c @@ -282,6 +282,9 @@ const struct helptxt helptext[] = { {" --http3", "Use HTTP v3", CURLHELP_HTTP}, + {" --http3-only", + "Use HTTP v3 only", + CURLHELP_HTTP}, {" --ignore-content-length", "Ignore the size of the remote resource", CURLHELP_HTTP | CURLHELP_FTP}, diff --git a/src/tool_setopt.c b/src/tool_setopt.c index fafd2d432..3279e8595 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -91,6 +91,7 @@ const struct NameValue setopt_nv_CURL_HTTP_VERSION[] = { NV(CURL_HTTP_VERSION_2_0), NV(CURL_HTTP_VERSION_2TLS), NV(CURL_HTTP_VERSION_3), + NV(CURL_HTTP_VERSION_3ONLY), NVEND, }; |