setopt: use the handler table for protocol name to number conversions

This also returns error CURLE_UNSUPPORTED_PROTOCOL rather than
CURLE_BAD_FUNCTION_ARGUMENT when a listed protocol name is not found.

A new schemelen parameter is added to Curl_builtin_scheme() to support
this extended use.

Note that disabled protocols are not recognized anymore.

Tests adapted accordingly.

Closes #9472
This commit is contained in:
Patrick Monnerat 2022-09-15 13:30:09 +02:00 committed by Daniel Stenberg
parent 1bbffa0833
commit 9d51329047
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 90 additions and 98 deletions

View file

@ -1700,7 +1700,7 @@ CURLcode Curl_follow(struct Curl_easy *data,
return Curl_uc_to_curlcode(uc);
}
p = Curl_builtin_scheme(scheme);
p = Curl_builtin_scheme(scheme, CURL_ZERO_TERMINATED);
if(p && (p->protocol != data->info.conn_protocol)) {
infof(data, "Clear auth, redirects scheme from %s to %s",
data->info.conn_scheme, scheme);