curl: return error when asked to use an unsupported HTTP version

When one of the following options are used but the libcurl in use does
not support it:

--http2
--http2-prior-knowledge
--proxy-http2

Closes #11440
This commit is contained in:
Daniel Stenberg 2023-07-15 14:00:09 +02:00
parent a70d97c46c
commit 8d7cda1f92
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 9 additions and 1 deletions

View File

@ -1438,10 +1438,14 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break;
case '2':
/* HTTP version 2.0 */
if(!feature_http2)
return PARAM_LIBCURL_DOESNT_SUPPORT;
sethttpver(global, config, CURL_HTTP_VERSION_2_0);
break;
case '3': /* --http2-prior-knowledge */
/* HTTP version 2.0 over clean TCP */
if(!feature_http2)
return PARAM_LIBCURL_DOESNT_SUPPORT;
sethttpver(global, config, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
break;
case '4': /* --http3 */
@ -1462,6 +1466,8 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break;
case 'a':
/* --proxy-http2 */
if(!feature_httpsproxy || !feature_http2)
return PARAM_LIBCURL_DOESNT_SUPPORT;
config->proxyver = CURLPROXY_HTTPS2;
break;
}

View File

@ -73,6 +73,7 @@ bool feature_brotli = FALSE;
bool feature_hsts = FALSE;
bool feature_http2 = FALSE;
bool feature_http3 = FALSE;
bool feature_httpsproxy = FALSE;
bool feature_libz = FALSE;
bool feature_ntlm = FALSE;
bool feature_ntlm_wb = FALSE;
@ -97,7 +98,7 @@ static struct feature_name_presentp {
{"HSTS", &feature_hsts, CURL_VERSION_HSTS},
{"HTTP2", &feature_http2, CURL_VERSION_HTTP2},
{"HTTP3", &feature_http3, CURL_VERSION_HTTP3},
{"HTTPS-proxy", NULL, CURL_VERSION_HTTPS_PROXY},
{"HTTPS-proxy", &feature_httpsproxy, CURL_VERSION_HTTPS_PROXY},
{"IDN", NULL, CURL_VERSION_IDN},
{"IPv6", NULL, CURL_VERSION_IPV6},
{"Kerberos", NULL, CURL_VERSION_KERBEROS5},

View File

@ -50,6 +50,7 @@ extern bool feature_brotli;
extern bool feature_hsts;
extern bool feature_http2;
extern bool feature_http3;
extern bool feature_httpsproxy;
extern bool feature_libz;
extern bool feature_ntlm;
extern bool feature_ntlm_wb;