summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/setopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/setopt.c')
-rw-r--r--libs/libcurl/src/setopt.c494
1 files changed, 253 insertions, 241 deletions
diff --git a/libs/libcurl/src/setopt.c b/libs/libcurl/src/setopt.c
index d02fca6c8f..349ddf6ae3 100644
--- a/libs/libcurl/src/setopt.c
+++ b/libs/libcurl/src/setopt.c
@@ -43,8 +43,9 @@
#include "strcase.h"
#include "share.h"
#include "vtls/vtls.h"
-#include "warnless.h"
+#include "curlx/warnless.h"
#include "sendf.h"
+#include "hostip.h"
#include "http2.h"
#include "setopt.h"
#include "multiif.h"
@@ -255,6 +256,157 @@ static CURLcode httpauth(struct Curl_easy *data, bool proxy,
return CURLE_OK;
}
+#ifndef CURL_DISABLE_HTTP
+static CURLcode setopt_HTTP_VERSION(struct Curl_easy *data, long arg)
+{
+ /*
+ * This sets a requested HTTP version to be used. The value is one of
+ * the listed enums in curl/curl.h.
+ */
+ switch(arg) {
+ case CURL_HTTP_VERSION_NONE:
+ /* accepted */
+ break;
+ case CURL_HTTP_VERSION_1_0:
+ case CURL_HTTP_VERSION_1_1:
+ /* accepted */
+ break;
+#ifdef USE_HTTP2
+ case CURL_HTTP_VERSION_2_0:
+ case CURL_HTTP_VERSION_2TLS:
+ case CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE:
+ /* accepted */
+ break;
+#endif
+#ifdef USE_HTTP3
+ case CURL_HTTP_VERSION_3:
+ case CURL_HTTP_VERSION_3ONLY:
+ /* accepted */
+ break;
+#endif
+ default:
+ /* not accepted */
+ if(arg < CURL_HTTP_VERSION_NONE)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
+ data->set.httpwant = (unsigned char)arg;
+ return CURLE_OK;
+}
+#endif /* ! CURL_DISABLE_HTTP */
+
+#ifdef USE_SSL
+static CURLcode setopt_SSLVERSION(struct Curl_easy *data, CURLoption option,
+ long arg)
+{
+ /*
+ * Set explicit SSL version to try to connect with, as some SSL
+ * implementations are lame.
+ */
+ {
+ long version, version_max;
+ struct ssl_primary_config *primary = &data->set.ssl.primary;
+#ifndef CURL_DISABLE_PROXY
+ if(option != CURLOPT_SSLVERSION)
+ primary = &data->set.proxy_ssl.primary;
+#else
+ if(option) {}
+#endif
+ version = C_SSLVERSION_VALUE(arg);
+ version_max = (long)C_SSLVERSION_MAX_VALUE(arg);
+
+ if(version < CURL_SSLVERSION_DEFAULT ||
+ version == CURL_SSLVERSION_SSLv2 ||
+ version == CURL_SSLVERSION_SSLv3 ||
+ version >= CURL_SSLVERSION_LAST ||
+ version_max < CURL_SSLVERSION_MAX_NONE ||
+ version_max >= CURL_SSLVERSION_MAX_LAST)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ primary->version = (unsigned char)version;
+ primary->version_max = (unsigned int)version_max;
+ }
+ return CURLE_OK;
+}
+#endif /* ! USE_SSL */
+
+#ifndef CURL_DISABLE_RTSP
+static CURLcode setopt_RTSP_REQUEST(struct Curl_easy *data, long arg)
+{
+ /*
+ * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
+ * Would this be better if the RTSPREQ_* were just moved into here?
+ */
+ Curl_RtspReq rtspreq = RTSPREQ_NONE;
+ switch(arg) {
+ case CURL_RTSPREQ_OPTIONS:
+ rtspreq = RTSPREQ_OPTIONS;
+ break;
+
+ case CURL_RTSPREQ_DESCRIBE:
+ rtspreq = RTSPREQ_DESCRIBE;
+ break;
+
+ case CURL_RTSPREQ_ANNOUNCE:
+ rtspreq = RTSPREQ_ANNOUNCE;
+ break;
+
+ case CURL_RTSPREQ_SETUP:
+ rtspreq = RTSPREQ_SETUP;
+ break;
+
+ case CURL_RTSPREQ_PLAY:
+ rtspreq = RTSPREQ_PLAY;
+ break;
+
+ case CURL_RTSPREQ_PAUSE:
+ rtspreq = RTSPREQ_PAUSE;
+ break;
+
+ case CURL_RTSPREQ_TEARDOWN:
+ rtspreq = RTSPREQ_TEARDOWN;
+ break;
+
+ case CURL_RTSPREQ_GET_PARAMETER:
+ rtspreq = RTSPREQ_GET_PARAMETER;
+ break;
+
+ case CURL_RTSPREQ_SET_PARAMETER:
+ rtspreq = RTSPREQ_SET_PARAMETER;
+ break;
+
+ case CURL_RTSPREQ_RECORD:
+ rtspreq = RTSPREQ_RECORD;
+ break;
+
+ case CURL_RTSPREQ_RECEIVE:
+ rtspreq = RTSPREQ_RECEIVE;
+ break;
+ default:
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+
+ data->set.rtspreq = rtspreq;
+ return CURLE_OK;
+}
+#endif /* ! CURL_DISABLE_RTSP */
+
+#ifdef USE_SSL
+static void set_ssl_options(struct ssl_config_data *ssl,
+ struct ssl_primary_config *config,
+ long arg)
+{
+ config->ssl_options = (unsigned char)(arg & 0xff);
+ ssl->enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
+ ssl->no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
+ ssl->no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
+ ssl->revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
+ ssl->native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
+ ssl->auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
+ ssl->earlydata = !!(arg & CURLSSLOPT_EARLYDATA);
+}
+#endif
+
static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
long arg)
{
@@ -290,7 +442,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.maxconnects = (unsigned int)uarg;
break;
- case CURLOPT_FORBID_REUSE:
+ case CURLOPT_FORBID_REUSE:
/*
* When this transfer is done, it must not be left to be reused by a
* subsequent transfer but shall be closed immediately.
@@ -321,11 +473,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
/*
* Shut off the internal supported progress meter
*/
- data->set.hide_progress = enabled;
- if(data->set.hide_progress)
- data->progress.flags |= PGRS_HIDE;
- else
- data->progress.flags &= ~PGRS_HIDE;
+ data->progress.hide = enabled;
break;
case CURLOPT_NOBODY:
/*
@@ -438,7 +586,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
*/
if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.timecondition = (unsigned char)(curl_TimeCond)arg;
+ data->set.timecondition = (unsigned char)arg;
break;
case CURLOPT_TIMEVALUE:
/*
@@ -451,36 +599,12 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSLVERSION:
#endif
- /*
- * Set explicit SSL version to try to connect with, as some SSL
- * implementations are lame.
- */
#ifdef USE_SSL
- {
- long version, version_max;
- struct ssl_primary_config *primary = &data->set.ssl.primary;
-#ifndef CURL_DISABLE_PROXY
- if(option != CURLOPT_SSLVERSION)
- primary = &data->set.proxy_ssl.primary;
-#endif
- version = C_SSLVERSION_VALUE(arg);
- version_max = (long)C_SSLVERSION_MAX_VALUE(arg);
-
- if(version < CURL_SSLVERSION_DEFAULT ||
- version == CURL_SSLVERSION_SSLv2 ||
- version == CURL_SSLVERSION_SSLv3 ||
- version >= CURL_SSLVERSION_LAST ||
- version_max < CURL_SSLVERSION_MAX_NONE ||
- version_max >= CURL_SSLVERSION_MAX_LAST)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- primary->version = (unsigned char)version;
- primary->version_max = (unsigned int)version_max;
- }
+ return setopt_SSLVERSION(data, option, arg);
#else
return CURLE_NOT_BUILT_IN;
#endif
- break;
+
case CURLOPT_POSTFIELDSIZE:
/*
* The size of the POSTFIELD data to prevent libcurl to do strlen() to
@@ -525,7 +649,9 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
/*
* Follow Location: header hints on an HTTP-server.
*/
- data->set.http_follow_location = enabled;
+ if(uarg > 3)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.http_follow_mode = (unsigned char)uarg;
break;
case CURLOPT_UNRESTRICTED_AUTH:
@@ -594,44 +720,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
break;
case CURLOPT_HTTP_VERSION:
- /*
- * This sets a requested HTTP version to be used. The value is one of
- * the listed enums in curl/curl.h.
- */
- switch(arg) {
- case CURL_HTTP_VERSION_NONE:
-#ifdef USE_HTTP2
- /* TODO: this seems an undesirable quirk to force a behaviour on
- * lower implementations that they should recognize independently? */
- arg = CURL_HTTP_VERSION_2TLS;
-#endif
- /* accepted */
- break;
- case CURL_HTTP_VERSION_1_0:
- case CURL_HTTP_VERSION_1_1:
- /* accepted */
- break;
-#ifdef USE_HTTP2
- case CURL_HTTP_VERSION_2_0:
- case CURL_HTTP_VERSION_2TLS:
- case CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE:
- /* accepted */
- break;
-#endif
-#ifdef USE_HTTP3
- case CURL_HTTP_VERSION_3:
- case CURL_HTTP_VERSION_3ONLY:
- /* accepted */
- break;
-#endif
- default:
- /* not accepted */
- if(arg < CURL_HTTP_VERSION_NONE)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- return CURLE_UNSUPPORTED_PROTOCOL;
- }
- data->set.httpwant = (unsigned char)arg;
- break;
+ return setopt_HTTP_VERSION(data, arg);
case CURLOPT_EXPECT_100_TIMEOUT_MS:
/*
@@ -644,13 +733,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
break;
case CURLOPT_HTTP09_ALLOWED:
-#ifdef USE_HYPER
- /* Hyper does not support HTTP/0.9 */
- if(enabled)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-#else
data->set.http09_allowed = enabled;
-#endif
break;
#endif /* ! CURL_DISABLE_HTTP */
@@ -698,7 +781,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
data->set.proxy_transfer_mode = (bool)uarg;
break;
case CURLOPT_SOCKS5_AUTH:
- if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
+ if(uarg & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
return CURLE_NOT_BUILT_IN;
data->set.socks5auth = (unsigned char)uarg;
break;
@@ -923,6 +1006,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
break;
#endif
+#ifdef HAVE_GSSAPI
case CURLOPT_GSSAPI_DELEGATION:
/*
* GSS-API credential delegation bitmask
@@ -930,6 +1014,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
data->set.gssapi_delegation = (unsigned char)uarg&
(CURLGSSAPI_DELEGATION_POLICY_FLAG|CURLGSSAPI_DELEGATION_FLAG);
break;
+#endif
case CURLOPT_SSL_VERIFYPEER:
/*
* Enable peer SSL verifying.
@@ -991,7 +1076,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
/*
* Enable TLS false start.
*/
- if(!Curl_ssl_false_start(data))
+ if(!Curl_ssl_false_start())
return CURLE_NOT_BUILT_IN;
data->set.ssl.falsestart = enabled;
@@ -1058,29 +1143,12 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
data->set.use_ssl = (unsigned char)arg;
break;
case CURLOPT_SSL_OPTIONS:
- data->set.ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
- data->set.ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
- data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
- data->set.ssl.revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
- data->set.ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
- data->set.ssl.auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
- data->set.ssl.earlydata = !!(arg & CURLSSLOPT_EARLYDATA);
- /* If a setting is added here it should also be added in dohprobe()
- which sets its own CURLOPT_SSL_OPTIONS based on these settings. */
+ set_ssl_options(&data->set.ssl, &data->set.ssl.primary, arg);
break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSL_OPTIONS:
- data->set.proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
- data->set.proxy_ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
- data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
- data->set.proxy_ssl.revoke_best_effort =
- !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
- data->set.proxy_ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
- data->set.proxy_ssl.auto_client_cert =
- !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
+ set_ssl_options(&data->set.proxy_ssl, &data->set.proxy_ssl.primary, arg);
break;
#endif
@@ -1110,7 +1178,8 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
*/
if(arg > 2)
return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.connect_only = (unsigned char)arg;
+ data->set.connect_only = !!arg;
+ data->set.connect_only_ws = (arg == 2);
break;
case CURLOPT_SSL_SESSIONID_CACHE:
@@ -1135,18 +1204,14 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
/*
* disable libcurl transfer encoding is used
*/
-#ifndef USE_HYPER
data->set.http_te_skip = !enabled; /* reversed */
break;
-#else
- return CURLE_NOT_BUILT_IN; /* hyper does not support */
-#endif
case CURLOPT_HTTP_CONTENT_DECODING:
/*
* raw data passed to the application when content encoding is used
*/
- data->set.http_ce_skip = enabled;
+ data->set.http_ce_skip = !enabled; /* reversed */
break;
#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
@@ -1210,63 +1275,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
break;
#ifndef CURL_DISABLE_RTSP
case CURLOPT_RTSP_REQUEST:
- {
- /*
- * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
- * Would this be better if the RTSPREQ_* were just moved into here?
- */
- Curl_RtspReq rtspreq = RTSPREQ_NONE;
- switch(arg) {
- case CURL_RTSPREQ_OPTIONS:
- rtspreq = RTSPREQ_OPTIONS;
- break;
-
- case CURL_RTSPREQ_DESCRIBE:
- rtspreq = RTSPREQ_DESCRIBE;
- break;
-
- case CURL_RTSPREQ_ANNOUNCE:
- rtspreq = RTSPREQ_ANNOUNCE;
- break;
-
- case CURL_RTSPREQ_SETUP:
- rtspreq = RTSPREQ_SETUP;
- break;
-
- case CURL_RTSPREQ_PLAY:
- rtspreq = RTSPREQ_PLAY;
- break;
-
- case CURL_RTSPREQ_PAUSE:
- rtspreq = RTSPREQ_PAUSE;
- break;
-
- case CURL_RTSPREQ_TEARDOWN:
- rtspreq = RTSPREQ_TEARDOWN;
- break;
-
- case CURL_RTSPREQ_GET_PARAMETER:
- rtspreq = RTSPREQ_GET_PARAMETER;
- break;
-
- case CURL_RTSPREQ_SET_PARAMETER:
- rtspreq = RTSPREQ_SET_PARAMETER;
- break;
-
- case CURL_RTSPREQ_RECORD:
- rtspreq = RTSPREQ_RECORD;
- break;
-
- case CURL_RTSPREQ_RECEIVE:
- rtspreq = RTSPREQ_RECEIVE;
- break;
- default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
- }
-
- data->set.rtspreq = rtspreq;
- break;
- }
+ return setopt_RTSP_REQUEST(data, arg);
case CURLOPT_RTSP_CLIENT_CSEQ:
/*
* Set the CSEQ number to issue for the next RTSP request. Useful if the
@@ -1394,7 +1403,8 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
#endif /* ! CURL_DISABLE_ALTSVC */
#ifndef CURL_DISABLE_WEBSOCKETS
case CURLOPT_WS_OPTIONS:
- data->set.ws_raw_mode = (bool)(arg & CURLWS_RAW_MODE);
+ data->set.ws_raw_mode = (bool)(arg & CURLWS_RAW_MODE);
+ data->set.ws_no_auto_pong = (bool)(arg & CURLWS_NOAUTOPONG);
break;
#endif
case CURLOPT_QUICK_EXIT:
@@ -1409,7 +1419,9 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
*/
Curl_safefree(data->set.str[STRING_SSL_ENGINE]);
return Curl_ssl_set_engine_default(data);
-
+ case CURLOPT_UPLOAD_FLAGS:
+ data->set.upload_flags = (unsigned char)arg;
+ break;
default:
/* unknown option */
return CURLE_UNKNOWN_OPTION;
@@ -1537,7 +1549,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_IMAP)
# ifndef CURL_DISABLE_MIME
- case CURLOPT_MIMEPOST:
+ case CURLOPT_MIMEPOST:
/*
* Set to make us do MIME POST
*/
@@ -1573,11 +1585,6 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
- if(data->dns.hostcachetype == HCACHE_SHARED) {
- data->dns.hostcache = NULL;
- data->dns.hostcachetype = HCACHE_NONE;
- }
-
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies == data->cookies)
data->cookies = NULL;
@@ -1587,14 +1594,14 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
if(data->share->hsts == data->hsts)
data->hsts = NULL;
#endif
-#ifdef USE_SSL
- if(data->share->sslsession == data->state.session)
- data->state.session = NULL;
-#endif
#ifdef USE_LIBPSL
if(data->psl == &data->share->psl)
data->psl = data->multi ? &data->multi->psl : NULL;
#endif
+ if(data->share->specifier & (1 << CURL_LOCK_DATA_DNS)) {
+ Curl_resolv_unlink(data, &data->state.dns[0]);
+ Curl_resolv_unlink(data, &data->state.dns[1]);
+ }
data->share->dirty--;
@@ -1611,11 +1618,6 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
data->share->dirty++;
- if(data->share->specifier & (1 << CURL_LOCK_DATA_DNS)) {
- /* use shared host cache */
- data->dns.hostcache = &data->share->hostcache;
- data->dns.hostcachetype = HCACHE_SHARED;
- }
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies) {
/* use shared cookie list, first free own one if any */
@@ -1631,12 +1633,6 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
data->hsts = data->share->hsts;
}
#endif
-#ifdef USE_SSL
- if(data->share->sslsession) {
- data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
- data->state.session = data->share->sslsession;
- }
-#endif
#ifdef USE_LIBPSL
if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
data->psl = &data->share->psl;
@@ -1675,8 +1671,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
if(Curl_ssl_supports(data, SSLSUPP_CIPHER_LIST))
/* set a list of cipher we want to use in the SSL connection */
return Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST], ptr);
- return CURLE_NOT_BUILT_IN;
- break;
+ else
+ return CURLE_NOT_BUILT_IN;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSL_CIPHER_LIST:
if(Curl_ssl_supports(data, SSLSUPP_CIPHER_LIST)) {
@@ -1686,7 +1682,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
}
else
return CURLE_NOT_BUILT_IN;
- break;
#endif
case CURLOPT_TLS13_CIPHERS:
if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES)) {
@@ -1695,7 +1690,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
}
else
return CURLE_NOT_BUILT_IN;
- break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_TLS13_CIPHERS:
if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES))
@@ -1704,7 +1698,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
ptr);
else
return CURLE_NOT_BUILT_IN;
- break;
#endif
case CURLOPT_RANDOM_FILE:
break;
@@ -1768,6 +1761,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
Curl_safefree(data->set.str[STRING_COPYPOSTFIELDS]);
data->set.method = HTTPREQ_POST;
break;
+#endif /* ! CURL_DISABLE_HTTP || ! CURL_DISABLE_MQTT */
#ifndef CURL_DISABLE_HTTP
case CURLOPT_ACCEPT_ENCODING:
@@ -1956,7 +1950,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
*/
return Curl_setstropt(&data->set.str[STRING_PROXY], ptr);
- break;
case CURLOPT_PRE_PROXY:
/*
@@ -1981,95 +1974,95 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO
*/
return Curl_setstropt(&data->set.str[STRING_SERVICE_NAME], ptr);
- break;
case CURLOPT_HEADERDATA:
/*
* Custom pointer to pass the header write callback function
*/
- data->set.writeheader = (void *)ptr;
+ data->set.writeheader = ptr;
break;
case CURLOPT_READDATA:
/*
* FILE pointer to read the file to be uploaded from. Or possibly used as
* argument to the read callback.
*/
- data->set.in_set = (void *)ptr;
+ data->set.in_set = ptr;
break;
case CURLOPT_WRITEDATA:
/*
* FILE pointer to write to. Or possibly used as argument to the write
* callback.
*/
- data->set.out = (void *)ptr;
+ data->set.out = ptr;
break;
case CURLOPT_DEBUGDATA:
/*
* Set to a void * that should receive all error writes. This
* defaults to CURLOPT_STDERR for normal operations.
*/
- data->set.debugdata = (void *)ptr;
+ data->set.debugdata = ptr;
break;
case CURLOPT_PROGRESSDATA:
/*
* Custom client data to pass to the progress callback
*/
- data->set.progress_client = (void *)ptr;
+ data->set.progress_client = ptr;
break;
case CURLOPT_SEEKDATA:
/*
* Seek control callback. Might be NULL.
*/
- data->set.seek_client = (void *)ptr;
+ data->set.seek_client = ptr;
break;
case CURLOPT_IOCTLDATA:
/*
* I/O control data pointer. Might be NULL.
*/
- data->set.ioctl_client = (void *)ptr;
+ data->set.ioctl_client = ptr;
break;
case CURLOPT_SSL_CTX_DATA:
/*
- * Set a SSL_CTX callback parameter pointer
+ * Set an SSL_CTX callback parameter pointer
*/
#ifdef USE_SSL
- if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX))
- data->set.ssl.fsslctxp = (void *)ptr;
+ if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) {
+ data->set.ssl.fsslctxp = ptr;
+ break;
+ }
else
#endif
return CURLE_NOT_BUILT_IN;
- break;
case CURLOPT_SOCKOPTDATA:
/*
* socket callback data pointer. Might be NULL.
*/
- data->set.sockopt_client = (void *)ptr;
+ data->set.sockopt_client = ptr;
break;
case CURLOPT_OPENSOCKETDATA:
/*
* socket callback data pointer. Might be NULL.
*/
- data->set.opensocket_client = (void *)ptr;
+ data->set.opensocket_client = ptr;
break;
case CURLOPT_RESOLVER_START_DATA:
/*
* resolver start callback data pointer. Might be NULL.
*/
- data->set.resolver_start_client = (void *)ptr;
+ data->set.resolver_start_client = ptr;
break;
case CURLOPT_CLOSESOCKETDATA:
/*
* socket callback data pointer. Might be NULL.
*/
- data->set.closesocket_client = (void *)ptr;
+ data->set.closesocket_client = ptr;
break;
case CURLOPT_TRAILERDATA:
#ifndef CURL_DISABLE_HTTP
- data->set.trailer_data = (void *)ptr;
+ data->set.trailer_data = ptr;
#endif
break;
case CURLOPT_PREREQDATA:
- data->set.prereq_userp = (void *)ptr;
+ data->set.prereq_userp = ptr;
break;
case CURLOPT_ERRORBUFFER:
@@ -2110,7 +2103,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* The URL to fetch.
*/
if(data->state.url_alloc) {
- /* the already set URL is allocated, free it first! */
Curl_safefree(data->state.url);
data->state.url_alloc = FALSE;
}
@@ -2159,12 +2151,16 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
result = setstropt_userpwd(ptr, &u, &p);
/* URL decode the components */
- if(!result && u)
+ if(!result && u) {
+ Curl_safefree(data->set.str[STRING_PROXYUSERNAME]);
result = Curl_urldecode(u, 0, &data->set.str[STRING_PROXYUSERNAME], NULL,
REJECT_ZERO);
- if(!result && p)
+ }
+ if(!result && p) {
+ Curl_safefree(data->set.str[STRING_PROXYPASSWORD]);
result = Curl_urldecode(p, 0, &data->set.str[STRING_PROXYPASSWORD], NULL,
REJECT_ZERO);
+ }
free(u);
free(p);
}
@@ -2186,7 +2182,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* proxy exception list
*/
return Curl_setstropt(&data->set.str[STRING_NOPROXY], ptr);
-#endif
+#endif /* ! CURL_DISABLE_PROXY */
case CURLOPT_RANGE:
/*
@@ -2194,11 +2190,17 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
*/
return Curl_setstropt(&data->set.str[STRING_SET_RANGE], ptr);
-#endif /* ! CURL_DISABLE_PROXY */
case CURLOPT_CURLU:
/*
* pass CURLU to set URL
*/
+ if(data->state.url_alloc) {
+ Curl_safefree(data->state.url);
+ data->state.url_alloc = FALSE;
+ }
+ else
+ data->state.url = NULL;
+ Curl_safefree(data->set.str[STRING_SET_URL]);
data->set.uh = (CURLU *)ptr;
break;
case CURLOPT_SSLCERT:
@@ -2227,6 +2229,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* String that holds file type of the SSL certificate to use for proxy
*/
return Curl_setstropt(&data->set.str[STRING_CERT_TYPE_PROXY], ptr);
+
#endif
case CURLOPT_SSLKEY:
/*
@@ -2247,7 +2250,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* String that holds file type of the SSL key to use
*/
return Curl_setstropt(&data->set.str[STRING_KEY_TYPE], ptr);
- break;
+
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSLKEYTYPE:
/*
@@ -2268,6 +2271,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* String that holds the SSL private key password for proxy.
*/
return Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY], ptr);
+
#endif
case CURLOPT_SSLENGINE:
/*
@@ -2290,6 +2294,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
/* enable the HAProxy protocol */
data->set.haproxyprotocol = TRUE;
break;
+
#endif
case CURLOPT_INTERFACE:
/*
@@ -2338,8 +2343,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* CA certificate
*/
return Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY], ptr);
-#endif
+#endif
case CURLOPT_CAPATH:
/*
* Set CA path info for SSL connection. Specify directory name of the CA
@@ -2378,6 +2383,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* CRL to check certificates revocation
*/
return Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY], ptr);
+
#endif
case CURLOPT_ISSUERCERT:
/*
@@ -2395,12 +2401,11 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
return Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_PROXY], ptr);
#endif
-
case CURLOPT_PRIVATE:
/*
* Set private data pointer.
*/
- data->set.private_data = (void *)ptr;
+ data->set.private_data = ptr;
break;
#ifdef USE_SSL
@@ -2410,6 +2415,16 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* Specify colon-delimited list of curve algorithm names.
*/
return Curl_setstropt(&data->set.str[STRING_SSL_EC_CURVES], ptr);
+
+ case CURLOPT_SSL_SIGNATURE_ALGORITHMS:
+ /*
+ * Set accepted signature algorithms.
+ * Specify colon-delimited list of signature scheme names.
+ */
+ if(Curl_ssl_supports(data, SSLSUPP_SIGNATURE_ALGORITHMS))
+ return Curl_setstropt(&data->set.str[STRING_SSL_SIGNATURE_ALGORITHMS],
+ ptr);
+ return CURLE_NOT_BUILT_IN;
#endif
#ifdef USE_SSH
case CURLOPT_SSH_PUBLIC_KEYFILE:
@@ -2424,6 +2439,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
*/
return Curl_setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY], ptr);
+#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
/*
* Option to allow for the MD5 of the host public key to be checked
@@ -2436,12 +2452,12 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* Store the filename to read known hosts from.
*/
return Curl_setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS], ptr);
-
+#endif
case CURLOPT_SSH_KEYDATA:
/*
* Custom client data to pass to the SSH keyfunc callback
*/
- data->set.ssh_keyfunc_userp = (void *)ptr;
+ data->set.ssh_keyfunc_userp = ptr;
break;
#ifdef USE_LIBSSH2
case CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256:
@@ -2456,7 +2472,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
/*
* Custom client data to pass to the SSH keyfunc callback
*/
- data->set.ssh_hostkeyfunc_userp = (void *)ptr;
+ data->set.ssh_hostkeyfunc_userp = ptr;
break;
#endif /* USE_LIBSSH2 */
#endif /* USE_SSH */
@@ -2487,7 +2503,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
/* Set the SMTP auth originator */
return Curl_setstropt(&data->set.str[STRING_MAIL_AUTH], ptr);
#endif
-
case CURLOPT_SASL_AUTHZID:
/* Authorization identity (identity to act as) */
return Curl_setstropt(&data->set.str[STRING_SASL_AUTHZID], ptr);
@@ -2506,7 +2521,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
* for generic server options, the application will need to set this.
*/
return Curl_setstropt(&data->set.str[STRING_RTSP_STREAM_URI], ptr);
- break;
case CURLOPT_RTSP_TRANSPORT:
/*
@@ -2515,15 +2529,15 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
return Curl_setstropt(&data->set.str[STRING_RTSP_TRANSPORT], ptr);
case CURLOPT_INTERLEAVEDATA:
- data->set.rtp_out = (void *)ptr;
+ data->set.rtp_out = ptr;
break;
#endif /* ! CURL_DISABLE_RTSP */
#ifndef CURL_DISABLE_FTP
case CURLOPT_CHUNK_DATA:
- data->set.wildcardptr = (void *)ptr;
+ data->set.wildcardptr = ptr;
break;
case CURLOPT_FNMATCH_DATA:
- data->set.fnmatch_data = (void *)ptr;
+ data->set.fnmatch_data = ptr;
break;
#endif
#ifdef USE_TLS_SRP
@@ -2553,30 +2567,30 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
break;
#endif
#endif
-#ifdef USE_ARES
+#ifdef CURLRES_ARES
case CURLOPT_DNS_SERVERS:
result = Curl_setstropt(&data->set.str[STRING_DNS_SERVERS], ptr);
if(result)
return result;
- return Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]);
+ return Curl_async_ares_set_dns_servers(data);
case CURLOPT_DNS_INTERFACE:
result = Curl_setstropt(&data->set.str[STRING_DNS_INTERFACE], ptr);
if(result)
return result;
- return Curl_set_dns_interface(data, data->set.str[STRING_DNS_INTERFACE]);
+ return Curl_async_ares_set_dns_interface(data);
case CURLOPT_DNS_LOCAL_IP4:
result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP4], ptr);
if(result)
return result;
- return Curl_set_dns_local_ip4(data, data->set.str[STRING_DNS_LOCAL_IP4]);
+ return Curl_async_ares_set_dns_local_ip4(data);
case CURLOPT_DNS_LOCAL_IP6:
result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP6], ptr);
if(result)
return result;
- return Curl_set_dns_local_ip6(data, data->set.str[STRING_DNS_LOCAL_IP6]);
+ return Curl_async_ares_set_dns_local_ip6(data);
#endif
#ifdef USE_UNIX_SOCKETS
@@ -2598,10 +2612,10 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
#endif
#ifndef CURL_DISABLE_HSTS
case CURLOPT_HSTSREADDATA:
- data->set.hsts_read_userp = (void *)ptr;
+ data->set.hsts_read_userp = ptr;
break;
case CURLOPT_HSTSWRITEDATA:
- data->set.hsts_write_userp = (void *)ptr;
+ data->set.hsts_write_userp = ptr;
break;
case CURLOPT_HSTS: {
struct curl_slist *h;
@@ -2773,15 +2787,16 @@ static CURLcode setopt_func(struct Curl_easy *data, CURLoption option,
break;
case CURLOPT_SSL_CTX_FUNCTION:
/*
- * Set a SSL_CTX callback
+ * Set an SSL_CTX callback
*/
#ifdef USE_SSL
- if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX))
+ if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) {
data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
+ break;
+ }
else
#endif
return CURLE_NOT_BUILT_IN;
- break;
case CURLOPT_SOCKOPTFUNCTION:
/*
@@ -2814,7 +2829,6 @@ static CURLcode setopt_func(struct Curl_easy *data, CURLoption option,
data->set.resolver_start = va_arg(param, curl_resolver_start_callback);
break;
-
#ifdef USE_SSH
#ifdef USE_LIBSSH2
case CURLOPT_SSH_HOSTKEYFUNCTION:
@@ -3079,9 +3093,7 @@ CURLcode curl_easy_setopt(CURL *d, CURLoption tag, ...)
result = Curl_vsetopt(data, tag, arg);
va_end(arg);
-#ifdef DEBUGBUILD
if(result == CURLE_BAD_FUNCTION_ARGUMENT)
- infof(data, "setopt arg 0x%x returned CURLE_BAD_FUNCTION_ARGUMENT", tag);
-#endif
+ failf(data, "setopt 0x%x got bad argument", tag);
return result;
}