1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 * SPDX-License-Identifier: curl
23 ***************************************************************************/
25 #include "curl_setup.h"
29 #ifdef HAVE_NETINET_IN_H
30 #include <netinet/in.h>
33 #ifdef HAVE_LINUX_TCP_H
34 #include <linux/tcp.h>
35 #elif defined(HAVE_NETINET_TCP_H)
36 #include <netinet/tcp.h>
42 #include "content_encoding.h"
45 #include "vtls/vtls.h"
54 /* The last 3 #include files should be in this order */
55 #include "curl_printf.h"
56 #include "curl_memory.h"
59 CURLcode Curl_setstropt(char **charp, const char *s)
61 /* Release the previous storage at `charp' and replace by a dynamic storage
62 copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
64 Curl_safefree(*charp);
67 if(strlen(s) > CURL_MAX_INPUT_LENGTH)
68 return CURLE_BAD_FUNCTION_ARGUMENT;
72 return CURLE_OUT_OF_MEMORY;
78 CURLcode Curl_setblobopt(struct curl_blob **blobp,
79 const struct curl_blob *blob)
81 /* free the previous storage at `blobp' and replace by a dynamic storage
82 copy of blob. If CURL_BLOB_COPY is set, the data is copied. */
84 Curl_safefree(*blobp);
87 struct curl_blob *nblob;
88 if(blob->len > CURL_MAX_INPUT_LENGTH)
89 return CURLE_BAD_FUNCTION_ARGUMENT;
90 nblob = (struct curl_blob *)
91 malloc(sizeof(struct curl_blob) +
92 ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0));
94 return CURLE_OUT_OF_MEMORY;
96 if(blob->flags & CURL_BLOB_COPY) {
97 /* put the data after the blob struct in memory */
98 nblob->data = (char *)nblob + sizeof(struct curl_blob);
99 memcpy(nblob->data, blob->data, blob->len);
109 static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
111 CURLcode result = CURLE_OK;
115 /* Parse the login details if specified. It not then we treat NULL as a hint
116 to clear the existing data */
118 result = Curl_parse_login_details(option, strlen(option),
119 (userp ? &user : NULL),
120 (passwdp ? &passwd : NULL),
125 /* Store the username part of option if required */
127 if(!user && option && option[0] == ':') {
128 /* Allocate an empty string instead of returning NULL as user name */
131 result = CURLE_OUT_OF_MEMORY;
134 Curl_safefree(*userp);
138 /* Store the password part of option if required */
140 Curl_safefree(*passwdp);
148 #define C_SSLVERSION_VALUE(x) (x & 0xffff)
149 #define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
151 static CURLcode protocol2num(const char *str, curl_prot_t *val)
154 return CURLE_BAD_FUNCTION_ARGUMENT;
156 if(curl_strequal(str, "all")) {
157 *val = ~(curl_prot_t) 0;
164 const char *token = str;
167 str = strchr(str, ',');
168 tlen = str? (size_t) (str - token): strlen(token);
170 const struct Curl_handler *h = Curl_builtin_scheme(token, tlen);
173 return CURLE_UNSUPPORTED_PROTOCOL;
180 /* no protocol listed */
181 return CURLE_BAD_FUNCTION_ARGUMENT;
186 * Do not make Curl_vsetopt() static: it is called from
187 * packages/OS400/ccsidcurl.c.
189 CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
192 CURLcode result = CURLE_OK;
198 case CURLOPT_DNS_CACHE_TIMEOUT:
199 arg = va_arg(param, long);
201 return CURLE_BAD_FUNCTION_ARGUMENT;
202 else if(arg > INT_MAX)
205 data->set.dns_cache_timeout = (int)arg;
207 case CURLOPT_DNS_USE_GLOBAL_CACHE:
210 case CURLOPT_SSL_CIPHER_LIST:
211 /* set a list of cipher we want to use in the SSL connection */
212 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST],
213 va_arg(param, char *));
215 #ifndef CURL_DISABLE_PROXY
216 case CURLOPT_PROXY_SSL_CIPHER_LIST:
217 /* set a list of cipher we want to use in the SSL connection for proxy */
218 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_PROXY],
219 va_arg(param, char *));
222 case CURLOPT_TLS13_CIPHERS:
223 if(Curl_ssl_tls13_ciphersuites()) {
224 /* set preferred list of TLS 1.3 cipher suites */
225 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST],
226 va_arg(param, char *));
229 return CURLE_NOT_BUILT_IN;
231 #ifndef CURL_DISABLE_PROXY
232 case CURLOPT_PROXY_TLS13_CIPHERS:
233 if(Curl_ssl_tls13_ciphersuites()) {
234 /* set preferred list of TLS 1.3 cipher suites for proxy */
235 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY],
236 va_arg(param, char *));
239 return CURLE_NOT_BUILT_IN;
242 case CURLOPT_RANDOM_FILE:
244 case CURLOPT_EGDSOCKET:
246 case CURLOPT_MAXCONNECTS:
248 * Set the absolute number of maximum simultaneous alive connection that
249 * libcurl is allowed to have.
251 arg = va_arg(param, long);
253 return CURLE_BAD_FUNCTION_ARGUMENT;
254 data->set.maxconnects = arg;
256 case CURLOPT_FORBID_REUSE:
258 * When this transfer is done, it must not be left to be reused by a
259 * subsequent transfer but shall be closed immediately.
261 data->set.reuse_forbid = (0 != va_arg(param, long)) ? TRUE : FALSE;
263 case CURLOPT_FRESH_CONNECT:
265 * This transfer shall not use a previously cached connection but
266 * should be made with a fresh new connect!
268 data->set.reuse_fresh = (0 != va_arg(param, long)) ? TRUE : FALSE;
270 case CURLOPT_VERBOSE:
272 * Verbose means infof() calls that give a lot of information about
273 * the connection and transfer procedures as well as internal choices.
275 data->set.verbose = (0 != va_arg(param, long)) ? TRUE : FALSE;
279 * Set to include the header in the general data output stream.
281 data->set.include_header = (0 != va_arg(param, long)) ? TRUE : FALSE;
283 case CURLOPT_NOPROGRESS:
285 * Shut off the internal supported progress meter
287 data->set.hide_progress = (0 != va_arg(param, long)) ? TRUE : FALSE;
288 if(data->set.hide_progress)
289 data->progress.flags |= PGRS_HIDE;
291 data->progress.flags &= ~PGRS_HIDE;
295 * Do not include the body part in the output data stream.
297 data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE;
298 #ifndef CURL_DISABLE_HTTP
299 if(data->set.opt_no_body)
300 /* in HTTP lingo, no body means using the HEAD request... */
301 data->set.method = HTTPREQ_HEAD;
302 else if(data->set.method == HTTPREQ_HEAD)
303 data->set.method = HTTPREQ_GET;
306 case CURLOPT_FAILONERROR:
308 * Don't output the >=400 error code HTML-page, but instead only
311 data->set.http_fail_on_error = (0 != va_arg(param, long)) ? TRUE : FALSE;
313 case CURLOPT_KEEP_SENDING_ON_ERROR:
314 data->set.http_keep_sending_on_error = (0 != va_arg(param, long)) ?
320 * We want to sent data to the remote host. If this is HTTP, that equals
321 * using the PUT request.
323 data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE;
324 if(data->set.upload) {
325 /* If this is HTTP, PUT is what's needed to "upload" */
326 data->set.method = HTTPREQ_PUT;
327 data->set.opt_no_body = FALSE; /* this is implied */
330 /* In HTTP, the opposite of upload is GET (unless NOBODY is true as
331 then this can be changed to HEAD later on) */
332 data->set.method = HTTPREQ_GET;
334 case CURLOPT_REQUEST_TARGET:
335 result = Curl_setstropt(&data->set.str[STRING_TARGET],
336 va_arg(param, char *));
338 case CURLOPT_FILETIME:
340 * Try to get the file time of the remote document. The time will
341 * later (possibly) become available using curl_easy_getinfo().
343 data->set.get_filetime = (0 != va_arg(param, long)) ? TRUE : FALSE;
345 case CURLOPT_SERVER_RESPONSE_TIMEOUT:
347 * Option that specifies how quickly a server response must be obtained
348 * before it is considered failure. For pingpong protocols.
350 arg = va_arg(param, long);
351 if((arg >= 0) && (arg <= (INT_MAX/1000)))
352 data->set.server_response_timeout = (unsigned int)arg * 1000;
354 return CURLE_BAD_FUNCTION_ARGUMENT;
356 #ifndef CURL_DISABLE_TFTP
357 case CURLOPT_TFTP_NO_OPTIONS:
359 * Option that prevents libcurl from sending TFTP option requests to the
362 data->set.tftp_no_options = va_arg(param, long) != 0;
364 case CURLOPT_TFTP_BLKSIZE:
366 * TFTP option that specifies the block size to use for data transmission.
368 arg = va_arg(param, long);
370 return CURLE_BAD_FUNCTION_ARGUMENT;
371 data->set.tftp_blksize = arg;
374 #ifndef CURL_DISABLE_NETRC
377 * Parse the $HOME/.netrc file
379 arg = va_arg(param, long);
380 if((arg < CURL_NETRC_IGNORED) || (arg >= CURL_NETRC_LAST))
381 return CURLE_BAD_FUNCTION_ARGUMENT;
382 data->set.use_netrc = (unsigned char)arg;
384 case CURLOPT_NETRC_FILE:
386 * Use this file instead of the $HOME/.netrc file
388 result = Curl_setstropt(&data->set.str[STRING_NETRC_FILE],
389 va_arg(param, char *));
392 case CURLOPT_TRANSFERTEXT:
394 * This option was previously named 'FTPASCII'. Renamed to work with
395 * more protocols than merely FTP.
397 * Transfer using ASCII (instead of BINARY).
399 data->set.prefer_ascii = (0 != va_arg(param, long)) ? TRUE : FALSE;
401 case CURLOPT_TIMECONDITION:
403 * Set HTTP time condition. This must be one of the defines in the
404 * curl/curl.h header file.
406 arg = va_arg(param, long);
407 if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST))
408 return CURLE_BAD_FUNCTION_ARGUMENT;
409 data->set.timecondition = (curl_TimeCond)arg;
411 case CURLOPT_TIMEVALUE:
413 * This is the value to compare with the remote document with the
414 * method set with CURLOPT_TIMECONDITION
416 data->set.timevalue = (time_t)va_arg(param, long);
419 case CURLOPT_TIMEVALUE_LARGE:
421 * This is the value to compare with the remote document with the
422 * method set with CURLOPT_TIMECONDITION
424 data->set.timevalue = (time_t)va_arg(param, curl_off_t);
427 case CURLOPT_SSLVERSION:
428 #ifndef CURL_DISABLE_PROXY
429 case CURLOPT_PROXY_SSLVERSION:
432 * Set explicit SSL version to try to connect with, as some SSL
433 * implementations are lame.
437 long version, version_max;
438 struct ssl_primary_config *primary = &data->set.ssl.primary;
439 #ifndef CURL_DISABLE_PROXY
440 if(option != CURLOPT_SSLVERSION)
441 primary = &data->set.proxy_ssl.primary;
444 arg = va_arg(param, long);
446 version = C_SSLVERSION_VALUE(arg);
447 version_max = C_SSLVERSION_MAX_VALUE(arg);
449 if(version < CURL_SSLVERSION_DEFAULT ||
450 version == CURL_SSLVERSION_SSLv2 ||
451 version == CURL_SSLVERSION_SSLv3 ||
452 version >= CURL_SSLVERSION_LAST ||
453 version_max < CURL_SSLVERSION_MAX_NONE ||
454 version_max >= CURL_SSLVERSION_MAX_LAST)
455 return CURLE_BAD_FUNCTION_ARGUMENT;
457 primary->version = version;
458 primary->version_max = version_max;
461 result = CURLE_NOT_BUILT_IN;
465 /* MQTT "borrows" some of the HTTP options */
466 #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MQTT)
467 case CURLOPT_COPYPOSTFIELDS:
469 * A string with POST data. Makes curl HTTP POST. Even if it is NULL.
470 * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
471 * CURLOPT_COPYPOSTFIELDS and not altered later.
473 argptr = va_arg(param, char *);
475 if(!argptr || data->set.postfieldsize == -1)
476 result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
479 * Check that requested length does not overflow the size_t type.
482 if((data->set.postfieldsize < 0) ||
483 ((sizeof(curl_off_t) != sizeof(size_t)) &&
484 (data->set.postfieldsize > (curl_off_t)((size_t)-1))))
485 result = CURLE_OUT_OF_MEMORY;
489 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
491 /* Allocate even when size == 0. This satisfies the need of possible
492 later address compare to detect the COPYPOSTFIELDS mode, and
493 to mark that postfields is used rather than read function or
496 p = malloc((size_t)(data->set.postfieldsize?
497 data->set.postfieldsize:1));
500 result = CURLE_OUT_OF_MEMORY;
502 if(data->set.postfieldsize)
503 memcpy(p, argptr, (size_t)data->set.postfieldsize);
505 data->set.str[STRING_COPYPOSTFIELDS] = p;
510 data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
511 data->set.method = HTTPREQ_POST;
514 case CURLOPT_POSTFIELDS:
516 * Like above, but use static data instead of copying it.
518 data->set.postfields = va_arg(param, void *);
519 /* Release old copied data. */
520 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
521 data->set.method = HTTPREQ_POST;
524 case CURLOPT_POSTFIELDSIZE:
526 * The size of the POSTFIELD data to prevent libcurl to do strlen() to
527 * figure it out. Enables binary posts.
529 bigsize = va_arg(param, long);
531 return CURLE_BAD_FUNCTION_ARGUMENT;
533 if(data->set.postfieldsize < bigsize &&
534 data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
535 /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
536 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
537 data->set.postfields = NULL;
540 data->set.postfieldsize = bigsize;
543 case CURLOPT_POSTFIELDSIZE_LARGE:
545 * The size of the POSTFIELD data to prevent libcurl to do strlen() to
546 * figure it out. Enables binary posts.
548 bigsize = va_arg(param, curl_off_t);
550 return CURLE_BAD_FUNCTION_ARGUMENT;
552 if(data->set.postfieldsize < bigsize &&
553 data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
554 /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
555 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
556 data->set.postfields = NULL;
559 data->set.postfieldsize = bigsize;
562 #ifndef CURL_DISABLE_HTTP
563 case CURLOPT_AUTOREFERER:
565 * Switch on automatic referer that gets set if curl follows locations.
567 data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
570 case CURLOPT_ACCEPT_ENCODING:
572 * String to use at the value of Accept-Encoding header.
574 * If the encoding is set to "" we use an Accept-Encoding header that
575 * encompasses all the encodings we support.
576 * If the encoding is set to NULL we don't send an Accept-Encoding header
577 * and ignore an received Content-Encoding header.
580 argptr = va_arg(param, char *);
581 if(argptr && !*argptr) {
582 argptr = Curl_all_content_encodings();
584 result = CURLE_OUT_OF_MEMORY;
586 result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
591 result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
594 case CURLOPT_TRANSFER_ENCODING:
595 data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
599 case CURLOPT_FOLLOWLOCATION:
601 * Follow Location: header hints on a HTTP-server.
603 data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
606 case CURLOPT_UNRESTRICTED_AUTH:
608 * Send authentication (user+password) when following locations, even when
611 data->set.allow_auth_to_other_hosts =
612 (0 != va_arg(param, long)) ? TRUE : FALSE;
615 case CURLOPT_MAXREDIRS:
617 * The maximum amount of hops you allow curl to follow Location:
618 * headers. This should mostly be used to detect never-ending loops.
620 arg = va_arg(param, long);
622 return CURLE_BAD_FUNCTION_ARGUMENT;
623 data->set.maxredirs = arg;
626 case CURLOPT_POSTREDIR:
628 * Set the behavior of POST when redirecting
629 * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
630 * CURL_REDIR_POST_301 - POST is kept as POST after 301
631 * CURL_REDIR_POST_302 - POST is kept as POST after 302
632 * CURL_REDIR_POST_303 - POST is kept as POST after 303
633 * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
634 * other - POST is kept as POST after 301 and 302
636 arg = va_arg(param, long);
637 if(arg < CURL_REDIR_GET_ALL)
638 /* no return error on too high numbers since the bitmask could be
639 extended in a future */
640 return CURLE_BAD_FUNCTION_ARGUMENT;
641 data->set.keep_post = arg & CURL_REDIR_POST_ALL;
645 /* Does this option serve a purpose anymore? Yes it does, when
646 CURLOPT_POSTFIELDS isn't used and the POST data is read off the
648 if(va_arg(param, long)) {
649 data->set.method = HTTPREQ_POST;
650 data->set.opt_no_body = FALSE; /* this is implied */
653 data->set.method = HTTPREQ_GET;
654 data->set.upload = FALSE;
657 #ifndef CURL_DISABLE_MIME
658 case CURLOPT_HTTPPOST:
660 * Set to make us do HTTP POST
662 data->set.httppost = va_arg(param, struct curl_httppost *);
663 data->set.method = HTTPREQ_POST_FORM;
664 data->set.opt_no_body = FALSE; /* this is implied */
668 case CURLOPT_AWS_SIGV4:
670 * String that is merged to some authentication
671 * parameters are used by the algorithm.
673 result = Curl_setstropt(&data->set.str[STRING_AWS_SIGV4],
674 va_arg(param, char *));
676 * Basic been set by default it need to be unset here
678 if(data->set.str[STRING_AWS_SIGV4])
679 data->set.httpauth = CURLAUTH_AWS_SIGV4;
682 case CURLOPT_REFERER:
684 * String to set in the HTTP Referer: field.
686 if(data->state.referer_alloc) {
687 Curl_safefree(data->state.referer);
688 data->state.referer_alloc = FALSE;
690 result = Curl_setstropt(&data->set.str[STRING_SET_REFERER],
691 va_arg(param, char *));
692 data->state.referer = data->set.str[STRING_SET_REFERER];
695 case CURLOPT_USERAGENT:
697 * String to use in the HTTP User-Agent field
699 result = Curl_setstropt(&data->set.str[STRING_USERAGENT],
700 va_arg(param, char *));
703 #ifndef CURL_DISABLE_PROXY
704 case CURLOPT_PROXYHEADER:
706 * Set a list with proxy headers to use (or replace internals with)
708 * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a
709 * long time we remain doing it this way until CURLOPT_PROXYHEADER is
710 * used. As soon as this option has been used, if set to anything but
711 * NULL, custom headers for proxies are only picked from this list.
713 * Set this option to NULL to restore the previous behavior.
715 data->set.proxyheaders = va_arg(param, struct curl_slist *);
718 case CURLOPT_HEADEROPT:
722 arg = va_arg(param, long);
723 data->set.sep_headers = (bool)((arg & CURLHEADER_SEPARATE)? TRUE: FALSE);
726 case CURLOPT_HTTP200ALIASES:
728 * Set a list of aliases for HTTP 200 in response header
730 data->set.http200aliases = va_arg(param, struct curl_slist *);
733 #if !defined(CURL_DISABLE_COOKIES)
736 * Cookie string to send to the remote server in the request.
738 result = Curl_setstropt(&data->set.str[STRING_COOKIE],
739 va_arg(param, char *));
742 case CURLOPT_COOKIEFILE:
744 * Set cookie file to read and parse. Can be used multiple times.
746 argptr = (char *)va_arg(param, void *);
748 struct curl_slist *cl;
749 /* general protection against mistakes and abuse */
750 if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
751 return CURLE_BAD_FUNCTION_ARGUMENT;
752 /* append the cookie file name to the list of file names, and deal with
754 cl = curl_slist_append(data->state.cookielist, argptr);
756 curl_slist_free_all(data->state.cookielist);
757 data->state.cookielist = NULL;
758 return CURLE_OUT_OF_MEMORY;
760 data->state.cookielist = cl; /* store the list for later use */
763 /* clear the list of cookie files */
764 curl_slist_free_all(data->state.cookielist);
765 data->state.cookielist = NULL;
767 if(!data->share || !data->share->cookies) {
768 /* throw away all existing cookies if this isn't a shared cookie
770 Curl_cookie_clearall(data->cookies);
771 Curl_cookie_cleanup(data->cookies);
773 /* disable the cookie engine */
774 data->cookies = NULL;
778 case CURLOPT_COOKIEJAR:
780 * Set cookie file name to dump all cookies to when we're done.
783 struct CookieInfo *newcookies;
784 result = Curl_setstropt(&data->set.str[STRING_COOKIEJAR],
785 va_arg(param, char *));
788 * Activate the cookie parser. This may or may not already
791 newcookies = Curl_cookie_init(data, NULL, data->cookies,
792 data->set.cookiesession);
794 result = CURLE_OUT_OF_MEMORY;
795 data->cookies = newcookies;
799 case CURLOPT_COOKIESESSION:
801 * Set this option to TRUE to start a new "cookie session". It will
802 * prevent the forthcoming read-cookies-from-file actions to accept
803 * cookies that are marked as being session cookies, as they belong to a
806 * In the original Netscape cookie spec, "session cookies" are cookies
807 * with no expire date set. RFC2109 describes the same action if no
808 * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds
809 * a 'Discard' action that can enforce the discard even for cookies that
812 * We run mostly with the original cookie spec, as hardly anyone implements
815 data->set.cookiesession = (0 != va_arg(param, long)) ? TRUE : FALSE;
818 case CURLOPT_COOKIELIST:
819 argptr = va_arg(param, char *);
824 if(strcasecompare(argptr, "ALL")) {
825 /* clear all cookies */
826 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
827 Curl_cookie_clearall(data->cookies);
828 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
830 else if(strcasecompare(argptr, "SESS")) {
831 /* clear session cookies */
832 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
833 Curl_cookie_clearsess(data->cookies);
834 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
836 else if(strcasecompare(argptr, "FLUSH")) {
837 /* flush cookies to file, takes care of the locking */
838 Curl_flush_cookies(data, FALSE);
840 else if(strcasecompare(argptr, "RELOAD")) {
841 /* reload cookies from file */
842 Curl_cookie_loadfiles(data);
847 /* if cookie engine was not running, activate it */
848 data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
850 /* general protection against mistakes and abuse */
851 if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
852 return CURLE_BAD_FUNCTION_ARGUMENT;
853 argptr = strdup(argptr);
854 if(!argptr || !data->cookies) {
855 result = CURLE_OUT_OF_MEMORY;
859 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
861 if(checkprefix("Set-Cookie:", argptr))
862 /* HTTP Header format line */
863 Curl_cookie_add(data, data->cookies, TRUE, FALSE, argptr + 11, NULL,
867 /* Netscape format line */
868 Curl_cookie_add(data, data->cookies, FALSE, FALSE, argptr, NULL,
871 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
877 #endif /* !CURL_DISABLE_COOKIES */
879 case CURLOPT_HTTPGET:
881 * Set to force us do HTTP GET
883 if(va_arg(param, long)) {
884 data->set.method = HTTPREQ_GET;
885 data->set.upload = FALSE; /* switch off upload */
886 data->set.opt_no_body = FALSE; /* this is implied */
890 case CURLOPT_HTTP_VERSION:
892 * This sets a requested HTTP version to be used. The value is one of
893 * the listed enums in curl/curl.h.
895 arg = va_arg(param, long);
896 if(arg < CURL_HTTP_VERSION_NONE)
897 return CURLE_BAD_FUNCTION_ARGUMENT;
899 if(arg == CURL_HTTP_VERSION_3)
904 if(arg >= CURL_HTTP_VERSION_2)
905 return CURLE_UNSUPPORTED_PROTOCOL;
907 if(arg >= CURL_HTTP_VERSION_LAST)
908 return CURLE_UNSUPPORTED_PROTOCOL;
909 if(arg == CURL_HTTP_VERSION_NONE)
910 arg = CURL_HTTP_VERSION_2TLS;
912 data->set.httpwant = (unsigned char)arg;
915 case CURLOPT_EXPECT_100_TIMEOUT_MS:
917 * Time to wait for a response to a HTTP request containing an
918 * Expect: 100-continue header before sending the data anyway.
920 arg = va_arg(param, long);
922 return CURLE_BAD_FUNCTION_ARGUMENT;
923 data->set.expect_100_timeout = arg;
926 case CURLOPT_HTTP09_ALLOWED:
927 arg = va_arg(param, unsigned long);
929 return CURLE_BAD_FUNCTION_ARGUMENT;
931 /* Hyper does not support HTTP/0.9 */
933 return CURLE_BAD_FUNCTION_ARGUMENT;
935 data->set.http09_allowed = arg ? TRUE : FALSE;
938 #endif /* CURL_DISABLE_HTTP */
940 #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
941 !defined(CURL_DISABLE_IMAP)
942 # if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MIME)
943 case CURLOPT_HTTPHEADER:
945 * Set a list with HTTP headers to use (or replace internals with)
947 data->set.headers = va_arg(param, struct curl_slist *);
951 # ifndef CURL_DISABLE_MIME
952 case CURLOPT_MIMEPOST:
954 * Set to make us do MIME POST
956 result = Curl_mime_set_subparts(&data->set.mimepost,
957 va_arg(param, curl_mime *), FALSE);
959 data->set.method = HTTPREQ_POST_MIME;
960 data->set.opt_no_body = FALSE; /* this is implied */
964 case CURLOPT_MIME_OPTIONS:
965 data->set.mime_options = (unsigned int)va_arg(param, long);
970 case CURLOPT_HTTPAUTH:
972 * Set HTTP Authentication type BITMASK.
977 unsigned long auth = va_arg(param, unsigned long);
979 if(auth == CURLAUTH_NONE) {
980 data->set.httpauth = auth;
984 /* the DIGEST_IE bit is only used to set a special marker, for all the
985 rest we need to handle it as normal DIGEST */
986 data->state.authhost.iestyle =
987 (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);
989 if(auth & CURLAUTH_DIGEST_IE) {
990 auth |= CURLAUTH_DIGEST; /* set standard digest bit */
991 auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
994 /* switch off bits we can't support */
996 auth &= ~CURLAUTH_NTLM; /* no NTLM support */
997 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
998 #elif !defined(NTLM_WB_ENABLED)
999 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
1002 auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
1006 /* check if any auth bit lower than CURLAUTH_ONLY is still set */
1009 while(bitcheck < 31) {
1010 if(auth & (1UL << bitcheck++)) {
1016 return CURLE_NOT_BUILT_IN; /* no supported types left! */
1018 data->set.httpauth = auth;
1022 case CURLOPT_CUSTOMREQUEST:
1024 * Set a custom string to use as request
1026 result = Curl_setstropt(&data->set.str[STRING_CUSTOMREQUEST],
1027 va_arg(param, char *));
1030 data->set.method = HTTPREQ_CUSTOM;
1031 here, we continue as if we were using the already set type
1032 and this just changes the actual request keyword */
1035 #ifndef CURL_DISABLE_PROXY
1036 case CURLOPT_HTTPPROXYTUNNEL:
1038 * Tunnel operations through the proxy instead of normal proxy use
1040 data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long)) ?
1044 case CURLOPT_PROXYPORT:
1046 * Explicitly set HTTP proxy port number.
1048 arg = va_arg(param, long);
1049 if((arg < 0) || (arg > 65535))
1050 return CURLE_BAD_FUNCTION_ARGUMENT;
1051 data->set.proxyport = arg;
1054 case CURLOPT_PROXYAUTH:
1056 * Set HTTP Authentication type BITMASK.
1061 unsigned long auth = va_arg(param, unsigned long);
1063 if(auth == CURLAUTH_NONE) {
1064 data->set.proxyauth = auth;
1068 /* the DIGEST_IE bit is only used to set a special marker, for all the
1069 rest we need to handle it as normal DIGEST */
1070 data->state.authproxy.iestyle =
1071 (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);
1073 if(auth & CURLAUTH_DIGEST_IE) {
1074 auth |= CURLAUTH_DIGEST; /* set standard digest bit */
1075 auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
1077 /* switch off bits we can't support */
1079 auth &= ~CURLAUTH_NTLM; /* no NTLM support */
1080 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
1081 #elif !defined(NTLM_WB_ENABLED)
1082 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
1085 auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
1089 /* check if any auth bit lower than CURLAUTH_ONLY is still set */
1092 while(bitcheck < 31) {
1093 if(auth & (1UL << bitcheck++)) {
1099 return CURLE_NOT_BUILT_IN; /* no supported types left! */
1101 data->set.proxyauth = auth;
1107 * Set proxy server:port to use as proxy.
1109 * If the proxy is set to "" (and CURLOPT_SOCKS_PROXY is set to "" or NULL)
1110 * we explicitly say that we don't want to use a proxy
1111 * (even though there might be environment variables saying so).
1113 * Setting it to NULL, means no proxy but allows the environment variables
1114 * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
1116 result = Curl_setstropt(&data->set.str[STRING_PROXY],
1117 va_arg(param, char *));
1120 case CURLOPT_PRE_PROXY:
1122 * Set proxy server:port to use as SOCKS proxy.
1124 * If the proxy is set to "" or NULL we explicitly say that we don't want
1125 * to use the socks proxy.
1127 result = Curl_setstropt(&data->set.str[STRING_PRE_PROXY],
1128 va_arg(param, char *));
1131 case CURLOPT_PROXYTYPE:
1133 * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
1135 arg = va_arg(param, long);
1136 if((arg < CURLPROXY_HTTP) || (arg > CURLPROXY_SOCKS5_HOSTNAME))
1137 return CURLE_BAD_FUNCTION_ARGUMENT;
1138 data->set.proxytype = (curl_proxytype)arg;
1141 case CURLOPT_PROXY_TRANSFER_MODE:
1143 * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
1145 switch(va_arg(param, long)) {
1147 data->set.proxy_transfer_mode = FALSE;
1150 data->set.proxy_transfer_mode = TRUE;
1153 /* reserve other values for future use */
1154 result = CURLE_BAD_FUNCTION_ARGUMENT;
1159 case CURLOPT_SOCKS5_AUTH:
1160 data->set.socks5auth = va_arg(param, unsigned long);
1161 if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
1162 result = CURLE_NOT_BUILT_IN;
1164 #endif /* CURL_DISABLE_PROXY */
1166 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1167 case CURLOPT_SOCKS5_GSSAPI_NEC:
1169 * Set flag for NEC SOCK5 support
1171 data->set.socks5_gssapi_nec = (0 != va_arg(param, long)) ? TRUE : FALSE;
1174 #ifndef CURL_DISABLE_PROXY
1175 case CURLOPT_SOCKS5_GSSAPI_SERVICE:
1176 case CURLOPT_PROXY_SERVICE_NAME:
1178 * Set proxy authentication service name for Kerberos 5 and SPNEGO
1180 result = Curl_setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME],
1181 va_arg(param, char *));
1184 case CURLOPT_SERVICE_NAME:
1186 * Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO
1188 result = Curl_setstropt(&data->set.str[STRING_SERVICE_NAME],
1189 va_arg(param, char *));
1192 case CURLOPT_HEADERDATA:
1194 * Custom pointer to pass the header write callback function
1196 data->set.writeheader = (void *)va_arg(param, void *);
1198 case CURLOPT_ERRORBUFFER:
1200 * Error buffer provided by the caller to get the human readable
1203 data->set.errorbuffer = va_arg(param, char *);
1205 case CURLOPT_WRITEDATA:
1207 * FILE pointer to write to. Or possibly
1208 * used as argument to the write callback.
1210 data->set.out = va_arg(param, void *);
1213 case CURLOPT_DIRLISTONLY:
1215 * An option that changes the command to one that asks for a list only, no
1216 * file info details. Used for FTP, POP3 and SFTP.
1218 data->set.list_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
1221 case CURLOPT_APPEND:
1223 * We want to upload and append to an existing file. Used for FTP and
1226 data->set.remote_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
1229 #ifndef CURL_DISABLE_FTP
1230 case CURLOPT_FTP_FILEMETHOD:
1232 * How do access files over FTP.
1234 arg = va_arg(param, long);
1235 if((arg < CURLFTPMETHOD_DEFAULT) || (arg >= CURLFTPMETHOD_LAST))
1236 return CURLE_BAD_FUNCTION_ARGUMENT;
1237 data->set.ftp_filemethod = (curl_ftpfile)arg;
1239 case CURLOPT_FTPPORT:
1241 * Use FTP PORT, this also specifies which IP address to use
1243 result = Curl_setstropt(&data->set.str[STRING_FTPPORT],
1244 va_arg(param, char *));
1245 data->set.ftp_use_port = (data->set.str[STRING_FTPPORT]) ? TRUE : FALSE;
1248 case CURLOPT_FTP_USE_EPRT:
1249 data->set.ftp_use_eprt = (0 != va_arg(param, long)) ? TRUE : FALSE;
1252 case CURLOPT_FTP_USE_EPSV:
1253 data->set.ftp_use_epsv = (0 != va_arg(param, long)) ? TRUE : FALSE;
1256 case CURLOPT_FTP_USE_PRET:
1257 data->set.ftp_use_pret = (0 != va_arg(param, long)) ? TRUE : FALSE;
1260 case CURLOPT_FTP_SSL_CCC:
1261 arg = va_arg(param, long);
1262 if((arg < CURLFTPSSL_CCC_NONE) || (arg >= CURLFTPSSL_CCC_LAST))
1263 return CURLE_BAD_FUNCTION_ARGUMENT;
1264 data->set.ftp_ccc = (curl_ftpccc)arg;
1267 case CURLOPT_FTP_SKIP_PASV_IP:
1269 * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
1270 * bypass of the IP address in PASV responses.
1272 data->set.ftp_skip_ip = (0 != va_arg(param, long)) ? TRUE : FALSE;
1275 case CURLOPT_FTP_ACCOUNT:
1276 result = Curl_setstropt(&data->set.str[STRING_FTP_ACCOUNT],
1277 va_arg(param, char *));
1280 case CURLOPT_FTP_ALTERNATIVE_TO_USER:
1281 result = Curl_setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],
1282 va_arg(param, char *));
1285 case CURLOPT_FTPSSLAUTH:
1287 * Set a specific auth for FTP-SSL transfers.
1289 arg = va_arg(param, long);
1290 if((arg < CURLFTPAUTH_DEFAULT) || (arg >= CURLFTPAUTH_LAST))
1291 return CURLE_BAD_FUNCTION_ARGUMENT;
1292 data->set.ftpsslauth = (curl_ftpauth)arg;
1294 case CURLOPT_KRBLEVEL:
1296 * A string that defines the kerberos security level.
1298 result = Curl_setstropt(&data->set.str[STRING_KRB_LEVEL],
1299 va_arg(param, char *));
1300 data->set.krb = (data->set.str[STRING_KRB_LEVEL]) ? TRUE : FALSE;
1303 case CURLOPT_FTP_CREATE_MISSING_DIRS:
1305 * An FTP/SFTP option that modifies an upload to create missing
1306 * directories on the server.
1308 arg = va_arg(param, long);
1309 /* reserve other values for future use */
1310 if((arg < CURLFTP_CREATE_DIR_NONE) ||
1311 (arg > CURLFTP_CREATE_DIR_RETRY))
1312 result = CURLE_BAD_FUNCTION_ARGUMENT;
1314 data->set.ftp_create_missing_dirs = (unsigned char)arg;
1316 case CURLOPT_READDATA:
1318 * FILE pointer to read the file to be uploaded from. Or possibly
1319 * used as argument to the read callback.
1321 data->set.in_set = va_arg(param, void *);
1323 case CURLOPT_INFILESIZE:
1325 * If known, this should inform curl about the file size of the
1326 * to-be-uploaded file.
1328 arg = va_arg(param, long);
1330 return CURLE_BAD_FUNCTION_ARGUMENT;
1331 data->set.filesize = arg;
1333 case CURLOPT_INFILESIZE_LARGE:
1335 * If known, this should inform curl about the file size of the
1336 * to-be-uploaded file.
1338 bigsize = va_arg(param, curl_off_t);
1340 return CURLE_BAD_FUNCTION_ARGUMENT;
1341 data->set.filesize = bigsize;
1343 case CURLOPT_LOW_SPEED_LIMIT:
1345 * The low speed limit that if transfers are below this for
1346 * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
1348 arg = va_arg(param, long);
1350 return CURLE_BAD_FUNCTION_ARGUMENT;
1351 data->set.low_speed_limit = arg;
1353 case CURLOPT_MAX_SEND_SPEED_LARGE:
1355 * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
1356 * bytes per second the transfer is throttled..
1358 bigsize = va_arg(param, curl_off_t);
1360 return CURLE_BAD_FUNCTION_ARGUMENT;
1361 data->set.max_send_speed = bigsize;
1363 case CURLOPT_MAX_RECV_SPEED_LARGE:
1365 * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
1366 * second the transfer is throttled..
1368 bigsize = va_arg(param, curl_off_t);
1370 return CURLE_BAD_FUNCTION_ARGUMENT;
1371 data->set.max_recv_speed = bigsize;
1373 case CURLOPT_LOW_SPEED_TIME:
1375 * The low speed time that if transfers are below the set
1376 * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
1378 arg = va_arg(param, long);
1380 return CURLE_BAD_FUNCTION_ARGUMENT;
1381 data->set.low_speed_time = arg;
1385 * pass CURLU to set URL
1387 data->set.uh = va_arg(param, CURLU *);
1393 if(data->state.url_alloc) {
1394 /* the already set URL is allocated, free it first! */
1395 Curl_safefree(data->state.url);
1396 data->state.url_alloc = FALSE;
1398 result = Curl_setstropt(&data->set.str[STRING_SET_URL],
1399 va_arg(param, char *));
1400 data->state.url = data->set.str[STRING_SET_URL];
1404 * The port number to use when getting the URL. 0 disables it.
1406 arg = va_arg(param, long);
1407 if((arg < 0) || (arg > 65535))
1408 return CURLE_BAD_FUNCTION_ARGUMENT;
1409 data->set.use_port = (unsigned short)arg;
1411 case CURLOPT_TIMEOUT:
1413 * The maximum time you allow curl to use for a single transfer
1416 arg = va_arg(param, long);
1417 if((arg >= 0) && (arg <= (INT_MAX/1000)))
1418 data->set.timeout = (unsigned int)arg * 1000;
1420 return CURLE_BAD_FUNCTION_ARGUMENT;
1423 case CURLOPT_TIMEOUT_MS:
1424 uarg = va_arg(param, unsigned long);
1425 if(uarg >= UINT_MAX)
1427 data->set.timeout = (unsigned int)uarg;
1430 case CURLOPT_CONNECTTIMEOUT:
1432 * The maximum time you allow curl to use to connect.
1434 arg = va_arg(param, long);
1435 if((arg >= 0) && (arg <= (INT_MAX/1000)))
1436 data->set.connecttimeout = (unsigned int)arg * 1000;
1438 return CURLE_BAD_FUNCTION_ARGUMENT;
1441 case CURLOPT_CONNECTTIMEOUT_MS:
1442 uarg = va_arg(param, unsigned long);
1443 if(uarg >= UINT_MAX)
1445 data->set.connecttimeout = (unsigned int)uarg;
1448 #ifndef CURL_DISABLE_FTP
1449 case CURLOPT_ACCEPTTIMEOUT_MS:
1451 * The maximum time for curl to wait for FTP server connect
1453 uarg = va_arg(param, unsigned long);
1454 if(uarg >= UINT_MAX)
1456 data->set.accepttimeout = (unsigned int)uarg;
1460 case CURLOPT_USERPWD:
1462 * user:password to use in the operation
1464 result = setstropt_userpwd(va_arg(param, char *),
1465 &data->set.str[STRING_USERNAME],
1466 &data->set.str[STRING_PASSWORD]);
1469 case CURLOPT_USERNAME:
1471 * authentication user name to use in the operation
1473 result = Curl_setstropt(&data->set.str[STRING_USERNAME],
1474 va_arg(param, char *));
1476 case CURLOPT_PASSWORD:
1478 * authentication password to use in the operation
1480 result = Curl_setstropt(&data->set.str[STRING_PASSWORD],
1481 va_arg(param, char *));
1484 case CURLOPT_LOGIN_OPTIONS:
1486 * authentication options to use in the operation
1488 result = Curl_setstropt(&data->set.str[STRING_OPTIONS],
1489 va_arg(param, char *));
1492 case CURLOPT_XOAUTH2_BEARER:
1494 * OAuth 2.0 bearer token to use in the operation
1496 result = Curl_setstropt(&data->set.str[STRING_BEARER],
1497 va_arg(param, char *));
1500 case CURLOPT_POSTQUOTE:
1502 * List of RAW FTP commands to use after a transfer
1504 data->set.postquote = va_arg(param, struct curl_slist *);
1506 case CURLOPT_PREQUOTE:
1508 * List of RAW FTP commands to use prior to RETR (Wesley Laxton)
1510 data->set.prequote = va_arg(param, struct curl_slist *);
1514 * List of RAW FTP commands to use before a transfer
1516 data->set.quote = va_arg(param, struct curl_slist *);
1518 case CURLOPT_RESOLVE:
1520 * List of HOST:PORT:[addresses] strings to populate the DNS cache with
1521 * Entries added this way will remain in the cache until explicitly
1522 * removed or the handle is cleaned up.
1524 * Prefix the HOST with plus sign (+) to have the entry expire just like
1525 * automatically added entries.
1527 * Prefix the HOST with dash (-) to _remove_ the entry from the cache.
1529 * This API can remove any entry from the DNS cache, but only entries
1530 * that aren't actually in use right now will be pruned immediately.
1532 data->set.resolve = va_arg(param, struct curl_slist *);
1533 data->state.resolve = data->set.resolve;
1535 case CURLOPT_PROGRESSFUNCTION:
1537 * Progress callback function
1539 data->set.fprogress = va_arg(param, curl_progress_callback);
1540 if(data->set.fprogress)
1541 data->progress.callback = TRUE; /* no longer internal */
1543 data->progress.callback = FALSE; /* NULL enforces internal */
1546 case CURLOPT_XFERINFOFUNCTION:
1548 * Transfer info callback function
1550 data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);
1551 if(data->set.fxferinfo)
1552 data->progress.callback = TRUE; /* no longer internal */
1554 data->progress.callback = FALSE; /* NULL enforces internal */
1558 case CURLOPT_PROGRESSDATA:
1560 * Custom client data to pass to the progress callback
1562 data->set.progress_client = va_arg(param, void *);
1565 #ifndef CURL_DISABLE_PROXY
1566 case CURLOPT_PROXYUSERPWD:
1568 * user:password needed to use the proxy
1570 result = setstropt_userpwd(va_arg(param, char *),
1571 &data->set.str[STRING_PROXYUSERNAME],
1572 &data->set.str[STRING_PROXYPASSWORD]);
1574 case CURLOPT_PROXYUSERNAME:
1576 * authentication user name to use in the operation
1578 result = Curl_setstropt(&data->set.str[STRING_PROXYUSERNAME],
1579 va_arg(param, char *));
1581 case CURLOPT_PROXYPASSWORD:
1583 * authentication password to use in the operation
1585 result = Curl_setstropt(&data->set.str[STRING_PROXYPASSWORD],
1586 va_arg(param, char *));
1588 case CURLOPT_NOPROXY:
1590 * proxy exception list
1592 result = Curl_setstropt(&data->set.str[STRING_NOPROXY],
1593 va_arg(param, char *));
1599 * What range of the file you want to transfer
1601 result = Curl_setstropt(&data->set.str[STRING_SET_RANGE],
1602 va_arg(param, char *));
1604 case CURLOPT_RESUME_FROM:
1606 * Resume transfer at the given file position
1608 arg = va_arg(param, long);
1610 return CURLE_BAD_FUNCTION_ARGUMENT;
1611 data->set.set_resume_from = arg;
1613 case CURLOPT_RESUME_FROM_LARGE:
1615 * Resume transfer at the given file position
1617 bigsize = va_arg(param, curl_off_t);
1619 return CURLE_BAD_FUNCTION_ARGUMENT;
1620 data->set.set_resume_from = bigsize;
1622 case CURLOPT_DEBUGFUNCTION:
1624 * stderr write callback.
1626 data->set.fdebug = va_arg(param, curl_debug_callback);
1628 * if the callback provided is NULL, it'll use the default callback
1631 case CURLOPT_DEBUGDATA:
1633 * Set to a void * that should receive all error writes. This
1634 * defaults to CURLOPT_STDERR for normal operations.
1636 data->set.debugdata = va_arg(param, void *);
1638 case CURLOPT_STDERR:
1640 * Set to a FILE * that should receive all error writes. This
1641 * defaults to stderr for normal operations.
1643 data->set.err = va_arg(param, FILE *);
1645 data->set.err = stderr;
1647 case CURLOPT_HEADERFUNCTION:
1649 * Set header write callback
1651 data->set.fwrite_header = va_arg(param, curl_write_callback);
1653 case CURLOPT_WRITEFUNCTION:
1655 * Set data write callback
1657 data->set.fwrite_func = va_arg(param, curl_write_callback);
1658 if(!data->set.fwrite_func)
1659 /* When set to NULL, reset to our internal default function */
1660 data->set.fwrite_func = (curl_write_callback)fwrite;
1662 case CURLOPT_READFUNCTION:
1664 * Read data callback
1666 data->set.fread_func_set = va_arg(param, curl_read_callback);
1667 if(!data->set.fread_func_set) {
1668 data->set.is_fread_set = 0;
1669 /* When set to NULL, reset to our internal default function */
1670 data->set.fread_func_set = (curl_read_callback)fread;
1673 data->set.is_fread_set = 1;
1675 case CURLOPT_SEEKFUNCTION:
1677 * Seek callback. Might be NULL.
1679 data->set.seek_func = va_arg(param, curl_seek_callback);
1681 case CURLOPT_SEEKDATA:
1683 * Seek control callback. Might be NULL.
1685 data->set.seek_client = va_arg(param, void *);
1687 case CURLOPT_IOCTLFUNCTION:
1689 * I/O control callback. Might be NULL.
1691 data->set.ioctl_func = va_arg(param, curl_ioctl_callback);
1693 case CURLOPT_IOCTLDATA:
1695 * I/O control data pointer. Might be NULL.
1697 data->set.ioctl_client = va_arg(param, void *);
1699 case CURLOPT_SSLCERT:
1701 * String that holds file name of the SSL certificate to use
1703 result = Curl_setstropt(&data->set.str[STRING_CERT],
1704 va_arg(param, char *));
1706 case CURLOPT_SSLCERT_BLOB:
1708 * Blob that holds file content of the SSL certificate to use
1710 result = Curl_setblobopt(&data->set.blobs[BLOB_CERT],
1711 va_arg(param, struct curl_blob *));
1713 #ifndef CURL_DISABLE_PROXY
1714 case CURLOPT_PROXY_SSLCERT:
1716 * String that holds file name of the SSL certificate to use for proxy
1718 result = Curl_setstropt(&data->set.str[STRING_CERT_PROXY],
1719 va_arg(param, char *));
1721 case CURLOPT_PROXY_SSLCERT_BLOB:
1723 * Blob that holds file content of the SSL certificate to use for proxy
1725 result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_PROXY],
1726 va_arg(param, struct curl_blob *));
1729 case CURLOPT_SSLCERTTYPE:
1731 * String that holds file type of the SSL certificate to use
1733 result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE],
1734 va_arg(param, char *));
1736 #ifndef CURL_DISABLE_PROXY
1737 case CURLOPT_PROXY_SSLCERTTYPE:
1739 * String that holds file type of the SSL certificate to use for proxy
1741 result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_PROXY],
1742 va_arg(param, char *));
1745 case CURLOPT_SSLKEY:
1747 * String that holds file name of the SSL key to use
1749 result = Curl_setstropt(&data->set.str[STRING_KEY],
1750 va_arg(param, char *));
1752 case CURLOPT_SSLKEY_BLOB:
1754 * Blob that holds file content of the SSL key to use
1756 result = Curl_setblobopt(&data->set.blobs[BLOB_KEY],
1757 va_arg(param, struct curl_blob *));
1759 #ifndef CURL_DISABLE_PROXY
1760 case CURLOPT_PROXY_SSLKEY:
1762 * String that holds file name of the SSL key to use for proxy
1764 result = Curl_setstropt(&data->set.str[STRING_KEY_PROXY],
1765 va_arg(param, char *));
1767 case CURLOPT_PROXY_SSLKEY_BLOB:
1769 * Blob that holds file content of the SSL key to use for proxy
1771 result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_PROXY],
1772 va_arg(param, struct curl_blob *));
1775 case CURLOPT_SSLKEYTYPE:
1777 * String that holds file type of the SSL key to use
1779 result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE],
1780 va_arg(param, char *));
1782 #ifndef CURL_DISABLE_PROXY
1783 case CURLOPT_PROXY_SSLKEYTYPE:
1785 * String that holds file type of the SSL key to use for proxy
1787 result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_PROXY],
1788 va_arg(param, char *));
1791 case CURLOPT_KEYPASSWD:
1793 * String that holds the SSL or SSH private key password.
1795 result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD],
1796 va_arg(param, char *));
1798 #ifndef CURL_DISABLE_PROXY
1799 case CURLOPT_PROXY_KEYPASSWD:
1801 * String that holds the SSL private key password for proxy.
1803 result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY],
1804 va_arg(param, char *));
1807 case CURLOPT_SSLENGINE:
1809 * String that holds the SSL crypto engine.
1811 argptr = va_arg(param, char *);
1812 if(argptr && argptr[0]) {
1813 result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr);
1815 result = Curl_ssl_set_engine(data, argptr);
1820 case CURLOPT_SSLENGINE_DEFAULT:
1822 * flag to set engine as default.
1824 Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL);
1825 result = Curl_ssl_set_engine_default(data);
1829 * Kludgy option to enable CRLF conversions. Subject for removal.
1831 data->set.crlf = (0 != va_arg(param, long)) ? TRUE : FALSE;
1833 #ifndef CURL_DISABLE_PROXY
1834 case CURLOPT_HAPROXYPROTOCOL:
1836 * Set to send the HAProxy Proxy Protocol header
1838 data->set.haproxyprotocol = (0 != va_arg(param, long)) ? TRUE : FALSE;
1841 case CURLOPT_INTERFACE:
1843 * Set what interface or address/hostname to bind the socket to when
1844 * performing an operation and thus what from-IP your connection will use.
1846 result = Curl_setstropt(&data->set.str[STRING_DEVICE],
1847 va_arg(param, char *));
1849 case CURLOPT_LOCALPORT:
1851 * Set what local port to bind the socket to when performing an operation.
1853 arg = va_arg(param, long);
1854 if((arg < 0) || (arg > 65535))
1855 return CURLE_BAD_FUNCTION_ARGUMENT;
1856 data->set.localport = curlx_sltous(arg);
1858 case CURLOPT_LOCALPORTRANGE:
1860 * Set number of local ports to try, starting with CURLOPT_LOCALPORT.
1862 arg = va_arg(param, long);
1863 if((arg < 0) || (arg > 65535))
1864 return CURLE_BAD_FUNCTION_ARGUMENT;
1865 data->set.localportrange = curlx_sltosi(arg);
1867 case CURLOPT_GSSAPI_DELEGATION:
1869 * GSS-API credential delegation bitmask
1871 arg = va_arg(param, long);
1872 if(arg < CURLGSSAPI_DELEGATION_NONE)
1873 return CURLE_BAD_FUNCTION_ARGUMENT;
1874 data->set.gssapi_delegation = arg;
1876 case CURLOPT_SSL_VERIFYPEER:
1878 * Enable peer SSL verifying.
1880 data->set.ssl.primary.verifypeer = (0 != va_arg(param, long)) ?
1883 /* Update the current connection ssl_config. */
1885 data->conn->ssl_config.verifypeer =
1886 data->set.ssl.primary.verifypeer;
1889 #ifndef CURL_DISABLE_DOH
1890 case CURLOPT_DOH_SSL_VERIFYPEER:
1892 * Enable peer SSL verifying for DoH.
1894 data->set.doh_verifypeer = (0 != va_arg(param, long)) ?
1898 #ifndef CURL_DISABLE_PROXY
1899 case CURLOPT_PROXY_SSL_VERIFYPEER:
1901 * Enable peer SSL verifying for proxy.
1903 data->set.proxy_ssl.primary.verifypeer =
1904 (0 != va_arg(param, long))?TRUE:FALSE;
1906 /* Update the current connection proxy_ssl_config. */
1908 data->conn->proxy_ssl_config.verifypeer =
1909 data->set.proxy_ssl.primary.verifypeer;
1913 case CURLOPT_SSL_VERIFYHOST:
1915 * Enable verification of the host name in the peer certificate
1917 arg = va_arg(param, long);
1919 /* Obviously people are not reading documentation and too many thought
1920 this argument took a boolean when it wasn't and misused it.
1921 Treat 1 and 2 the same */
1922 data->set.ssl.primary.verifyhost = (bool)((arg & 3) ? TRUE : FALSE);
1924 /* Update the current connection ssl_config. */
1926 data->conn->ssl_config.verifyhost =
1927 data->set.ssl.primary.verifyhost;
1930 #ifndef CURL_DISABLE_DOH
1931 case CURLOPT_DOH_SSL_VERIFYHOST:
1933 * Enable verification of the host name in the peer certificate for DoH
1935 arg = va_arg(param, long);
1937 /* Treat both 1 and 2 as TRUE */
1938 data->set.doh_verifyhost = (bool)((arg & 3) ? TRUE : FALSE);
1941 #ifndef CURL_DISABLE_PROXY
1942 case CURLOPT_PROXY_SSL_VERIFYHOST:
1944 * Enable verification of the host name in the peer certificate for proxy
1946 arg = va_arg(param, long);
1948 /* Treat both 1 and 2 as TRUE */
1949 data->set.proxy_ssl.primary.verifyhost = (bool)((arg & 3)?TRUE:FALSE);
1951 /* Update the current connection proxy_ssl_config. */
1953 data->conn->proxy_ssl_config.verifyhost =
1954 data->set.proxy_ssl.primary.verifyhost;
1958 case CURLOPT_SSL_VERIFYSTATUS:
1960 * Enable certificate status verifying.
1962 if(!Curl_ssl_cert_status_request()) {
1963 result = CURLE_NOT_BUILT_IN;
1967 data->set.ssl.primary.verifystatus = (0 != va_arg(param, long)) ?
1970 /* Update the current connection ssl_config. */
1972 data->conn->ssl_config.verifystatus =
1973 data->set.ssl.primary.verifystatus;
1976 #ifndef CURL_DISABLE_DOH
1977 case CURLOPT_DOH_SSL_VERIFYSTATUS:
1979 * Enable certificate status verifying for DoH.
1981 if(!Curl_ssl_cert_status_request()) {
1982 result = CURLE_NOT_BUILT_IN;
1986 data->set.doh_verifystatus = (0 != va_arg(param, long)) ?
1990 case CURLOPT_SSL_CTX_FUNCTION:
1992 * Set a SSL_CTX callback
1995 if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
1996 data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
1999 result = CURLE_NOT_BUILT_IN;
2001 case CURLOPT_SSL_CTX_DATA:
2003 * Set a SSL_CTX callback parameter pointer
2006 if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
2007 data->set.ssl.fsslctxp = va_arg(param, void *);
2010 result = CURLE_NOT_BUILT_IN;
2012 case CURLOPT_SSL_FALSESTART:
2014 * Enable TLS false start.
2016 if(!Curl_ssl_false_start()) {
2017 result = CURLE_NOT_BUILT_IN;
2021 data->set.ssl.falsestart = (0 != va_arg(param, long)) ? TRUE : FALSE;
2023 case CURLOPT_CERTINFO:
2025 if(Curl_ssl->supports & SSLSUPP_CERTINFO)
2026 data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE;
2029 result = CURLE_NOT_BUILT_IN;
2031 case CURLOPT_PINNEDPUBLICKEY:
2033 * Set pinned public key for SSL connection.
2034 * Specify file name of the public key in DER format.
2037 if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
2038 result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY],
2039 va_arg(param, char *));
2042 result = CURLE_NOT_BUILT_IN;
2044 #ifndef CURL_DISABLE_PROXY
2045 case CURLOPT_PROXY_PINNEDPUBLICKEY:
2047 * Set pinned public key for SSL connection.
2048 * Specify file name of the public key in DER format.
2051 if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
2052 result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
2053 va_arg(param, char *));
2056 result = CURLE_NOT_BUILT_IN;
2059 case CURLOPT_CAINFO:
2061 * Set CA info for SSL connection. Specify file name of the CA certificate
2063 result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE],
2064 va_arg(param, char *));
2066 case CURLOPT_CAINFO_BLOB:
2068 * Blob that holds CA info for SSL connection.
2069 * Specify entire PEM of the CA certificate
2072 if(Curl_ssl->supports & SSLSUPP_CAINFO_BLOB)
2073 result = Curl_setblobopt(&data->set.blobs[BLOB_CAINFO],
2074 va_arg(param, struct curl_blob *));
2077 return CURLE_NOT_BUILT_IN;
2080 #ifndef CURL_DISABLE_PROXY
2081 case CURLOPT_PROXY_CAINFO:
2083 * Set CA info SSL connection for proxy. Specify file name of the
2086 result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY],
2087 va_arg(param, char *));
2089 case CURLOPT_PROXY_CAINFO_BLOB:
2091 * Blob that holds CA info for SSL connection proxy.
2092 * Specify entire PEM of the CA certificate
2095 if(Curl_ssl->supports & SSLSUPP_CAINFO_BLOB)
2096 result = Curl_setblobopt(&data->set.blobs[BLOB_CAINFO_PROXY],
2097 va_arg(param, struct curl_blob *));
2100 return CURLE_NOT_BUILT_IN;
2103 case CURLOPT_CAPATH:
2105 * Set CA path info for SSL connection. Specify directory name of the CA
2106 * certificates which have been prepared using openssl c_rehash utility.
2109 if(Curl_ssl->supports & SSLSUPP_CA_PATH)
2110 /* This does not work on windows. */
2111 result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH],
2112 va_arg(param, char *));
2115 result = CURLE_NOT_BUILT_IN;
2117 #ifndef CURL_DISABLE_PROXY
2118 case CURLOPT_PROXY_CAPATH:
2120 * Set CA path info for SSL connection proxy. Specify directory name of the
2121 * CA certificates which have been prepared using openssl c_rehash utility.
2124 if(Curl_ssl->supports & SSLSUPP_CA_PATH)
2125 /* This does not work on windows. */
2126 result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY],
2127 va_arg(param, char *));
2130 result = CURLE_NOT_BUILT_IN;
2133 case CURLOPT_CRLFILE:
2135 * Set CRL file info for SSL connection. Specify file name of the CRL
2136 * to check certificates revocation
2138 result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE],
2139 va_arg(param, char *));
2141 #ifndef CURL_DISABLE_PROXY
2142 case CURLOPT_PROXY_CRLFILE:
2144 * Set CRL file info for SSL connection for proxy. Specify file name of the
2145 * CRL to check certificates revocation
2147 result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY],
2148 va_arg(param, char *));
2151 case CURLOPT_ISSUERCERT:
2153 * Set Issuer certificate file
2154 * to check certificates issuer
2156 result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT],
2157 va_arg(param, char *));
2159 case CURLOPT_ISSUERCERT_BLOB:
2161 * Blob that holds Issuer certificate to check certificates issuer
2163 result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT],
2164 va_arg(param, struct curl_blob *));
2166 #ifndef CURL_DISABLE_PROXY
2167 case CURLOPT_PROXY_ISSUERCERT:
2169 * Set Issuer certificate file
2170 * to check certificates issuer
2172 result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_PROXY],
2173 va_arg(param, char *));
2175 case CURLOPT_PROXY_ISSUERCERT_BLOB:
2177 * Blob that holds Issuer certificate to check certificates issuer
2179 result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY],
2180 va_arg(param, struct curl_blob *));
2183 #ifndef CURL_DISABLE_TELNET
2184 case CURLOPT_TELNETOPTIONS:
2186 * Set a linked list of telnet options
2188 data->set.telnet_options = va_arg(param, struct curl_slist *);
2191 case CURLOPT_BUFFERSIZE:
2193 * The application kindly asks for a differently sized receive buffer.
2194 * If it seems reasonable, we'll use it.
2196 if(data->state.buffer)
2197 return CURLE_BAD_FUNCTION_ARGUMENT;
2199 arg = va_arg(param, long);
2201 if(arg > READBUFFER_MAX)
2202 arg = READBUFFER_MAX;
2204 arg = READBUFFER_SIZE;
2205 else if(arg < READBUFFER_MIN)
2206 arg = READBUFFER_MIN;
2208 data->set.buffer_size = (int)arg;
2211 case CURLOPT_UPLOAD_BUFFERSIZE:
2213 * The application kindly asks for a differently sized upload buffer.
2214 * Cap it to sensible.
2216 arg = va_arg(param, long);
2218 if(arg > UPLOADBUFFER_MAX)
2219 arg = UPLOADBUFFER_MAX;
2220 else if(arg < UPLOADBUFFER_MIN)
2221 arg = UPLOADBUFFER_MIN;
2223 data->set.upload_buffer_size = (unsigned int)arg;
2224 Curl_safefree(data->state.ulbuf); /* force a realloc next opportunity */
2227 case CURLOPT_NOSIGNAL:
2229 * The application asks not to set any signal() or alarm() handlers,
2230 * even when using a timeout.
2232 data->set.no_signal = (0 != va_arg(param, long)) ? TRUE : FALSE;
2237 struct Curl_share *set;
2238 set = va_arg(param, struct Curl_share *);
2240 /* disconnect from old share, if any */
2242 Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
2244 if(data->dns.hostcachetype == HCACHE_SHARED) {
2245 data->dns.hostcache = NULL;
2246 data->dns.hostcachetype = HCACHE_NONE;
2249 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
2250 if(data->share->cookies == data->cookies)
2251 data->cookies = NULL;
2254 if(data->share->sslsession == data->state.session)
2255 data->state.session = NULL;
2258 if(data->psl == &data->share->psl)
2259 data->psl = data->multi? &data->multi->psl: NULL;
2262 data->share->dirty--;
2264 Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
2268 if(GOOD_SHARE_HANDLE(set))
2269 /* use new share if it set */
2273 Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
2275 data->share->dirty++;
2277 if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) {
2278 /* use shared host cache */
2279 data->dns.hostcache = &data->share->hostcache;
2280 data->dns.hostcachetype = HCACHE_SHARED;
2282 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
2283 if(data->share->cookies) {
2284 /* use shared cookie list, first free own one if any */
2285 Curl_cookie_cleanup(data->cookies);
2286 /* enable cookies since we now use a share that uses cookies! */
2287 data->cookies = data->share->cookies;
2289 #endif /* CURL_DISABLE_HTTP */
2290 if(data->share->sslsession) {
2291 data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
2292 data->state.session = data->share->sslsession;
2295 if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
2296 data->psl = &data->share->psl;
2299 Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
2301 /* check for host cache not needed,
2302 * it will be done by curl_easy_perform */
2306 case CURLOPT_PRIVATE:
2308 * Set private data pointer.
2310 data->set.private_data = va_arg(param, void *);
2313 case CURLOPT_MAXFILESIZE:
2315 * Set the maximum size of a file to download.
2317 arg = va_arg(param, long);
2319 return CURLE_BAD_FUNCTION_ARGUMENT;
2320 data->set.max_filesize = arg;
2324 case CURLOPT_USE_SSL:
2326 * Make transfers attempt to use SSL/TLS.
2328 arg = va_arg(param, long);
2329 if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST))
2330 return CURLE_BAD_FUNCTION_ARGUMENT;
2331 data->set.use_ssl = (curl_usessl)arg;
2334 case CURLOPT_SSL_OPTIONS:
2335 arg = va_arg(param, long);
2336 data->set.ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
2337 data->set.ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
2338 data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
2339 data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
2340 data->set.ssl.revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
2341 data->set.ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
2342 data->set.ssl.auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
2343 /* If a setting is added here it should also be added in dohprobe()
2344 which sets its own CURLOPT_SSL_OPTIONS based on these settings. */
2347 #ifndef CURL_DISABLE_PROXY
2348 case CURLOPT_PROXY_SSL_OPTIONS:
2349 arg = va_arg(param, long);
2350 data->set.proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
2351 data->set.proxy_ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
2352 data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
2353 data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
2354 data->set.proxy_ssl.revoke_best_effort =
2355 !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
2356 data->set.proxy_ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
2357 data->set.proxy_ssl.auto_client_cert =
2358 !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
2362 case CURLOPT_SSL_EC_CURVES:
2364 * Set accepted curves in SSL connection setup.
2365 * Specify colon-delimited list of curve algorithm names.
2367 result = Curl_setstropt(&data->set.str[STRING_SSL_EC_CURVES],
2368 va_arg(param, char *));
2371 case CURLOPT_IPRESOLVE:
2372 arg = va_arg(param, long);
2373 if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6))
2374 return CURLE_BAD_FUNCTION_ARGUMENT;
2375 data->set.ipver = (unsigned char) arg;
2378 case CURLOPT_MAXFILESIZE_LARGE:
2380 * Set the maximum size of a file to download.
2382 bigsize = va_arg(param, curl_off_t);
2384 return CURLE_BAD_FUNCTION_ARGUMENT;
2385 data->set.max_filesize = bigsize;
2388 case CURLOPT_TCP_NODELAY:
2390 * Enable or disable TCP_NODELAY, which will disable/enable the Nagle
2393 data->set.tcp_nodelay = (0 != va_arg(param, long)) ? TRUE : FALSE;
2396 case CURLOPT_IGNORE_CONTENT_LENGTH:
2397 data->set.ignorecl = (0 != va_arg(param, long)) ? TRUE : FALSE;
2400 case CURLOPT_CONNECT_ONLY:
2403 * (1) - only do connection
2404 * (2) - do first get request but get no content
2406 arg = va_arg(param, long);
2408 return CURLE_BAD_FUNCTION_ARGUMENT;
2409 data->set.connect_only = (unsigned char)arg;
2412 case CURLOPT_SOCKOPTFUNCTION:
2414 * socket callback function: called after socket() but before connect()
2416 data->set.fsockopt = va_arg(param, curl_sockopt_callback);
2419 case CURLOPT_SOCKOPTDATA:
2421 * socket callback data pointer. Might be NULL.
2423 data->set.sockopt_client = va_arg(param, void *);
2426 case CURLOPT_OPENSOCKETFUNCTION:
2428 * open/create socket callback function: called instead of socket(),
2431 data->set.fopensocket = va_arg(param, curl_opensocket_callback);
2434 case CURLOPT_OPENSOCKETDATA:
2436 * socket callback data pointer. Might be NULL.
2438 data->set.opensocket_client = va_arg(param, void *);
2441 case CURLOPT_CLOSESOCKETFUNCTION:
2443 * close socket callback function: called instead of close()
2444 * when shutting down a connection
2446 data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
2449 case CURLOPT_RESOLVER_START_FUNCTION:
2451 * resolver start callback function: called before a new resolver request
2454 data->set.resolver_start = va_arg(param, curl_resolver_start_callback);
2457 case CURLOPT_RESOLVER_START_DATA:
2459 * resolver start callback data pointer. Might be NULL.
2461 data->set.resolver_start_client = va_arg(param, void *);
2464 case CURLOPT_CLOSESOCKETDATA:
2466 * socket callback data pointer. Might be NULL.
2468 data->set.closesocket_client = va_arg(param, void *);
2471 case CURLOPT_SSL_SESSIONID_CACHE:
2472 data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ?
2474 #ifndef CURL_DISABLE_PROXY
2475 data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
2480 /* we only include SSH options if explicitly built to support SSH */
2481 case CURLOPT_SSH_AUTH_TYPES:
2482 data->set.ssh_auth_types = (unsigned int)va_arg(param, long);
2485 case CURLOPT_SSH_PUBLIC_KEYFILE:
2487 * Use this file instead of the $HOME/.ssh/id_dsa.pub file
2489 result = Curl_setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],
2490 va_arg(param, char *));
2493 case CURLOPT_SSH_PRIVATE_KEYFILE:
2495 * Use this file instead of the $HOME/.ssh/id_dsa file
2497 result = Curl_setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],
2498 va_arg(param, char *));
2500 case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
2502 * Option to allow for the MD5 of the host public key to be checked
2503 * for validation purposes.
2505 result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],
2506 va_arg(param, char *));
2509 case CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256:
2511 * Option to allow for the SHA256 of the host public key to be checked
2512 * for validation purposes.
2514 result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_SHA256],
2515 va_arg(param, char *));
2518 case CURLOPT_SSH_KNOWNHOSTS:
2520 * Store the file name to read known hosts from.
2522 result = Curl_setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],
2523 va_arg(param, char *));
2526 case CURLOPT_SSH_HOSTKEYFUNCTION:
2527 /* the callback to check the hostkey without the knownhost file */
2528 data->set.ssh_hostkeyfunc = va_arg(param, curl_sshhostkeycallback);
2531 case CURLOPT_SSH_HOSTKEYDATA:
2533 * Custom client data to pass to the SSH keyfunc callback
2535 data->set.ssh_hostkeyfunc_userp = va_arg(param, void *);
2538 case CURLOPT_SSH_KEYFUNCTION:
2539 /* setting to NULL is fine since the ssh.c functions themselves will
2540 then revert to use the internal default */
2541 data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
2544 case CURLOPT_SSH_KEYDATA:
2546 * Custom client data to pass to the SSH keyfunc callback
2548 data->set.ssh_keyfunc_userp = va_arg(param, void *);
2551 case CURLOPT_SSH_COMPRESSION:
2552 data->set.ssh_compression = (0 != va_arg(param, long))?TRUE:FALSE;
2554 #endif /* USE_SSH */
2556 case CURLOPT_HTTP_TRANSFER_DECODING:
2558 * disable libcurl transfer encoding is used
2561 data->set.http_te_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
2564 return CURLE_NOT_BUILT_IN; /* hyper doesn't support */
2567 case CURLOPT_HTTP_CONTENT_DECODING:
2569 * raw data passed to the application when content encoding is used
2571 data->set.http_ce_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
2574 #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
2575 case CURLOPT_NEW_FILE_PERMS:
2577 * Uses these permissions instead of 0644
2579 arg = va_arg(param, long);
2580 if((arg < 0) || (arg > 0777))
2581 return CURLE_BAD_FUNCTION_ARGUMENT;
2582 data->set.new_file_perms = (unsigned int)arg;
2585 case CURLOPT_NEW_DIRECTORY_PERMS:
2587 * Uses these permissions instead of 0755
2589 arg = va_arg(param, long);
2590 if((arg < 0) || (arg > 0777))
2591 return CURLE_BAD_FUNCTION_ARGUMENT;
2592 data->set.new_directory_perms = (unsigned int)arg;
2597 case CURLOPT_ADDRESS_SCOPE:
2599 * Use this scope id when using IPv6
2600 * We always get longs when passed plain numericals so we should check
2601 * that the value fits into an unsigned 32 bit integer.
2603 uarg = va_arg(param, unsigned long);
2606 return CURLE_BAD_FUNCTION_ARGUMENT;
2608 data->set.scope_id = (unsigned int)uarg;
2612 case CURLOPT_PROTOCOLS:
2613 /* set the bitmask for the protocols that are allowed to be used for the
2614 transfer, which thus helps the app which takes URLs from users or other
2615 external inputs and want to restrict what protocol(s) to deal
2616 with. Defaults to CURLPROTO_ALL. */
2617 data->set.allowed_protocols = (curl_prot_t)va_arg(param, long);
2620 case CURLOPT_REDIR_PROTOCOLS:
2621 /* set the bitmask for the protocols that libcurl is allowed to follow to,
2622 as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
2623 to be set in both bitmasks to be allowed to get redirected to. */
2624 data->set.redir_protocols = (curl_prot_t)va_arg(param, long);
2627 case CURLOPT_PROTOCOLS_STR: {
2629 argptr = va_arg(param, char *);
2630 result = protocol2num(argptr, &prot);
2633 data->set.allowed_protocols = prot;
2637 case CURLOPT_REDIR_PROTOCOLS_STR: {
2639 argptr = va_arg(param, char *);
2640 result = protocol2num(argptr, &prot);
2643 data->set.redir_protocols = prot;
2647 case CURLOPT_DEFAULT_PROTOCOL:
2648 /* Set the protocol to use when the URL doesn't include any protocol */
2649 result = Curl_setstropt(&data->set.str[STRING_DEFAULT_PROTOCOL],
2650 va_arg(param, char *));
2652 #ifndef CURL_DISABLE_SMTP
2653 case CURLOPT_MAIL_FROM:
2654 /* Set the SMTP mail originator */
2655 result = Curl_setstropt(&data->set.str[STRING_MAIL_FROM],
2656 va_arg(param, char *));
2659 case CURLOPT_MAIL_AUTH:
2660 /* Set the SMTP auth originator */
2661 result = Curl_setstropt(&data->set.str[STRING_MAIL_AUTH],
2662 va_arg(param, char *));
2665 case CURLOPT_MAIL_RCPT:
2666 /* Set the list of mail recipients */
2667 data->set.mail_rcpt = va_arg(param, struct curl_slist *);
2669 case CURLOPT_MAIL_RCPT_ALLLOWFAILS:
2670 /* allow RCPT TO command to fail for some recipients */
2671 data->set.mail_rcpt_allowfails = (0 != va_arg(param, long)) ? TRUE : FALSE;
2675 case CURLOPT_SASL_AUTHZID:
2676 /* Authorization identity (identity to act as) */
2677 result = Curl_setstropt(&data->set.str[STRING_SASL_AUTHZID],
2678 va_arg(param, char *));
2681 case CURLOPT_SASL_IR:
2682 /* Enable/disable SASL initial response */
2683 data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;
2685 #ifndef CURL_DISABLE_RTSP
2686 case CURLOPT_RTSP_REQUEST:
2689 * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
2690 * Would this be better if the RTSPREQ_* were just moved into here?
2692 long in_rtspreq = va_arg(param, long);
2693 Curl_RtspReq rtspreq = RTSPREQ_NONE;
2694 switch(in_rtspreq) {
2695 case CURL_RTSPREQ_OPTIONS:
2696 rtspreq = RTSPREQ_OPTIONS;
2699 case CURL_RTSPREQ_DESCRIBE:
2700 rtspreq = RTSPREQ_DESCRIBE;
2703 case CURL_RTSPREQ_ANNOUNCE:
2704 rtspreq = RTSPREQ_ANNOUNCE;
2707 case CURL_RTSPREQ_SETUP:
2708 rtspreq = RTSPREQ_SETUP;
2711 case CURL_RTSPREQ_PLAY:
2712 rtspreq = RTSPREQ_PLAY;
2715 case CURL_RTSPREQ_PAUSE:
2716 rtspreq = RTSPREQ_PAUSE;
2719 case CURL_RTSPREQ_TEARDOWN:
2720 rtspreq = RTSPREQ_TEARDOWN;
2723 case CURL_RTSPREQ_GET_PARAMETER:
2724 rtspreq = RTSPREQ_GET_PARAMETER;
2727 case CURL_RTSPREQ_SET_PARAMETER:
2728 rtspreq = RTSPREQ_SET_PARAMETER;
2731 case CURL_RTSPREQ_RECORD:
2732 rtspreq = RTSPREQ_RECORD;
2735 case CURL_RTSPREQ_RECEIVE:
2736 rtspreq = RTSPREQ_RECEIVE;
2739 rtspreq = RTSPREQ_NONE;
2742 data->set.rtspreq = rtspreq;
2747 case CURLOPT_RTSP_SESSION_ID:
2749 * Set the RTSP Session ID manually. Useful if the application is
2750 * resuming a previously established RTSP session
2752 result = Curl_setstropt(&data->set.str[STRING_RTSP_SESSION_ID],
2753 va_arg(param, char *));
2756 case CURLOPT_RTSP_STREAM_URI:
2758 * Set the Stream URI for the RTSP request. Unless the request is
2759 * for generic server options, the application will need to set this.
2761 result = Curl_setstropt(&data->set.str[STRING_RTSP_STREAM_URI],
2762 va_arg(param, char *));
2765 case CURLOPT_RTSP_TRANSPORT:
2767 * The content of the Transport: header for the RTSP request
2769 result = Curl_setstropt(&data->set.str[STRING_RTSP_TRANSPORT],
2770 va_arg(param, char *));
2773 case CURLOPT_RTSP_CLIENT_CSEQ:
2775 * Set the CSEQ number to issue for the next RTSP request. Useful if the
2776 * application is resuming a previously broken connection. The CSEQ
2777 * will increment from this new number henceforth.
2779 data->state.rtsp_next_client_CSeq = va_arg(param, long);
2782 case CURLOPT_RTSP_SERVER_CSEQ:
2783 /* Same as the above, but for server-initiated requests */
2784 data->state.rtsp_next_server_CSeq = va_arg(param, long);
2787 case CURLOPT_INTERLEAVEDATA:
2788 data->set.rtp_out = va_arg(param, void *);
2790 case CURLOPT_INTERLEAVEFUNCTION:
2791 /* Set the user defined RTP write function */
2792 data->set.fwrite_rtp = va_arg(param, curl_write_callback);
2795 #ifndef CURL_DISABLE_FTP
2796 case CURLOPT_WILDCARDMATCH:
2797 data->set.wildcard_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE;
2799 case CURLOPT_CHUNK_BGN_FUNCTION:
2800 data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
2802 case CURLOPT_CHUNK_END_FUNCTION:
2803 data->set.chunk_end = va_arg(param, curl_chunk_end_callback);
2805 case CURLOPT_FNMATCH_FUNCTION:
2806 data->set.fnmatch = va_arg(param, curl_fnmatch_callback);
2808 case CURLOPT_CHUNK_DATA:
2809 data->wildcard.customptr = va_arg(param, void *);
2811 case CURLOPT_FNMATCH_DATA:
2812 data->set.fnmatch_data = va_arg(param, void *);
2816 case CURLOPT_TLSAUTH_USERNAME:
2817 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
2818 va_arg(param, char *));
2819 if(data->set.str[STRING_TLSAUTH_USERNAME] &&
2820 !data->set.ssl.primary.authtype)
2821 data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
2823 #ifndef CURL_DISABLE_PROXY
2824 case CURLOPT_PROXY_TLSAUTH_USERNAME:
2825 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
2826 va_arg(param, char *));
2827 if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2828 !data->set.proxy_ssl.primary.authtype)
2829 data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to
2833 case CURLOPT_TLSAUTH_PASSWORD:
2834 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
2835 va_arg(param, char *));
2836 if(data->set.str[STRING_TLSAUTH_USERNAME] &&
2837 !data->set.ssl.primary.authtype)
2838 data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
2840 #ifndef CURL_DISABLE_PROXY
2841 case CURLOPT_PROXY_TLSAUTH_PASSWORD:
2842 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
2843 va_arg(param, char *));
2844 if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2845 !data->set.proxy_ssl.primary.authtype)
2846 data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
2849 case CURLOPT_TLSAUTH_TYPE:
2850 argptr = va_arg(param, char *);
2852 strncasecompare(argptr, "SRP", strlen("SRP")))
2853 data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP;
2855 data->set.ssl.primary.authtype = CURL_TLSAUTH_NONE;
2857 #ifndef CURL_DISABLE_PROXY
2858 case CURLOPT_PROXY_TLSAUTH_TYPE:
2859 argptr = va_arg(param, char *);
2861 strncasecompare(argptr, "SRP", strlen("SRP")))
2862 data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP;
2864 data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_NONE;
2869 case CURLOPT_DNS_SERVERS:
2870 result = Curl_setstropt(&data->set.str[STRING_DNS_SERVERS],
2871 va_arg(param, char *));
2874 result = Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]);
2876 case CURLOPT_DNS_INTERFACE:
2877 result = Curl_setstropt(&data->set.str[STRING_DNS_INTERFACE],
2878 va_arg(param, char *));
2881 result = Curl_set_dns_interface(data, data->set.str[STRING_DNS_INTERFACE]);
2883 case CURLOPT_DNS_LOCAL_IP4:
2884 result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP4],
2885 va_arg(param, char *));
2888 result = Curl_set_dns_local_ip4(data, data->set.str[STRING_DNS_LOCAL_IP4]);
2890 case CURLOPT_DNS_LOCAL_IP6:
2891 result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP6],
2892 va_arg(param, char *));
2895 result = Curl_set_dns_local_ip6(data, data->set.str[STRING_DNS_LOCAL_IP6]);
2898 case CURLOPT_TCP_KEEPALIVE:
2899 data->set.tcp_keepalive = (0 != va_arg(param, long)) ? TRUE : FALSE;
2901 case CURLOPT_TCP_KEEPIDLE:
2902 arg = va_arg(param, long);
2904 return CURLE_BAD_FUNCTION_ARGUMENT;
2905 else if(arg > INT_MAX)
2907 data->set.tcp_keepidle = (int)arg;
2909 case CURLOPT_TCP_KEEPINTVL:
2910 arg = va_arg(param, long);
2912 return CURLE_BAD_FUNCTION_ARGUMENT;
2913 else if(arg > INT_MAX)
2915 data->set.tcp_keepintvl = (int)arg;
2917 case CURLOPT_TCP_FASTOPEN:
2918 #if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
2919 defined(TCP_FASTOPEN_CONNECT)
2920 data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE;
2922 result = CURLE_NOT_BUILT_IN;
2925 case CURLOPT_SSL_ENABLE_NPN:
2927 case CURLOPT_SSL_ENABLE_ALPN:
2928 data->set.ssl_enable_alpn = (0 != va_arg(param, long)) ? TRUE : FALSE;
2930 #ifdef USE_UNIX_SOCKETS
2931 case CURLOPT_UNIX_SOCKET_PATH:
2932 data->set.abstract_unix_socket = FALSE;
2933 result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
2934 va_arg(param, char *));
2936 case CURLOPT_ABSTRACT_UNIX_SOCKET:
2937 data->set.abstract_unix_socket = TRUE;
2938 result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
2939 va_arg(param, char *));
2943 case CURLOPT_PATH_AS_IS:
2944 data->set.path_as_is = (0 != va_arg(param, long)) ? TRUE : FALSE;
2946 case CURLOPT_PIPEWAIT:
2947 data->set.pipewait = (0 != va_arg(param, long)) ? TRUE : FALSE;
2949 case CURLOPT_STREAM_WEIGHT:
2951 return CURLE_NOT_BUILT_IN;
2953 arg = va_arg(param, long);
2954 if((arg >= 1) && (arg <= 256))
2955 data->set.stream_weight = (int)arg;
2958 case CURLOPT_STREAM_DEPENDS:
2959 case CURLOPT_STREAM_DEPENDS_E:
2962 return CURLE_NOT_BUILT_IN;
2964 struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
2965 if(!dep || GOOD_EASY_HANDLE(dep)) {
2966 if(data->set.stream_depends_on) {
2967 Curl_http2_remove_child(data->set.stream_depends_on, data);
2969 Curl_http2_add_child(dep, data, (option == CURLOPT_STREAM_DEPENDS_E));
2974 case CURLOPT_CONNECT_TO:
2975 data->set.connect_to = va_arg(param, struct curl_slist *);
2977 case CURLOPT_SUPPRESS_CONNECT_HEADERS:
2978 data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE;
2980 case CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS:
2981 uarg = va_arg(param, unsigned long);
2982 if(uarg >= UINT_MAX)
2984 data->set.happy_eyeballs_timeout = (unsigned int)uarg;
2986 #ifndef CURL_DISABLE_SHUFFLE_DNS
2987 case CURLOPT_DNS_SHUFFLE_ADDRESSES:
2988 data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE;
2991 case CURLOPT_DISALLOW_USERNAME_IN_URL:
2992 data->set.disallow_username_in_url =
2993 (0 != va_arg(param, long)) ? TRUE : FALSE;
2995 #ifndef CURL_DISABLE_DOH
2996 case CURLOPT_DOH_URL:
2997 result = Curl_setstropt(&data->set.str[STRING_DOH],
2998 va_arg(param, char *));
2999 data->set.doh = data->set.str[STRING_DOH]?TRUE:FALSE;
3002 case CURLOPT_UPKEEP_INTERVAL_MS:
3003 arg = va_arg(param, long);
3005 return CURLE_BAD_FUNCTION_ARGUMENT;
3006 data->set.upkeep_interval_ms = arg;
3008 case CURLOPT_MAXAGE_CONN:
3009 arg = va_arg(param, long);
3011 return CURLE_BAD_FUNCTION_ARGUMENT;
3012 data->set.maxage_conn = arg;
3014 case CURLOPT_MAXLIFETIME_CONN:
3015 arg = va_arg(param, long);
3017 return CURLE_BAD_FUNCTION_ARGUMENT;
3018 data->set.maxlifetime_conn = arg;
3020 case CURLOPT_TRAILERFUNCTION:
3021 #ifndef CURL_DISABLE_HTTP
3022 data->set.trailer_callback = va_arg(param, curl_trailer_callback);
3025 case CURLOPT_TRAILERDATA:
3026 #ifndef CURL_DISABLE_HTTP
3027 data->set.trailer_data = va_arg(param, void *);
3030 #ifndef CURL_DISABLE_HSTS
3031 case CURLOPT_HSTSREADFUNCTION:
3032 data->set.hsts_read = va_arg(param, curl_hstsread_callback);
3034 case CURLOPT_HSTSREADDATA:
3035 data->set.hsts_read_userp = va_arg(param, void *);
3037 case CURLOPT_HSTSWRITEFUNCTION:
3038 data->set.hsts_write = va_arg(param, curl_hstswrite_callback);
3040 case CURLOPT_HSTSWRITEDATA:
3041 data->set.hsts_write_userp = va_arg(param, void *);
3045 data->hsts = Curl_hsts_init();
3047 return CURLE_OUT_OF_MEMORY;
3049 argptr = va_arg(param, char *);
3050 result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr);
3054 (void)Curl_hsts_loadfile(data, data->hsts, argptr);
3056 case CURLOPT_HSTS_CTRL:
3057 arg = va_arg(param, long);
3058 if(arg & CURLHSTS_ENABLE) {
3060 data->hsts = Curl_hsts_init();
3062 return CURLE_OUT_OF_MEMORY;
3066 Curl_hsts_cleanup(&data->hsts);
3069 #ifndef CURL_DISABLE_ALTSVC
3070 case CURLOPT_ALTSVC:
3072 data->asi = Curl_altsvc_init();
3074 return CURLE_OUT_OF_MEMORY;
3076 argptr = va_arg(param, char *);
3077 result = Curl_setstropt(&data->set.str[STRING_ALTSVC], argptr);
3081 (void)Curl_altsvc_load(data->asi, argptr);
3083 case CURLOPT_ALTSVC_CTRL:
3085 data->asi = Curl_altsvc_init();
3087 return CURLE_OUT_OF_MEMORY;
3089 arg = va_arg(param, long);
3090 result = Curl_altsvc_ctrl(data->asi, arg);
3095 case CURLOPT_PREREQFUNCTION:
3096 data->set.fprereq = va_arg(param, curl_prereq_callback);
3098 case CURLOPT_PREREQDATA:
3099 data->set.prereq_userp = va_arg(param, void *);
3101 #ifdef USE_WEBSOCKETS
3102 case CURLOPT_WS_OPTIONS: {
3104 arg = va_arg(param, long);
3105 raw = (arg & CURLWS_RAW_MODE);
3106 data->set.ws_raw_mode = raw;
3111 /* unknown tag and its companion, just ignore: */
3112 result = CURLE_UNKNOWN_OPTION;
3120 * curl_easy_setopt() is the external interface for setting options on an
3123 * NOTE: This is one of few API functions that are allowed to be called from
3124 * within a callback.
3127 #undef curl_easy_setopt
3128 CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
3134 return CURLE_BAD_FUNCTION_ARGUMENT;
3138 result = Curl_vsetopt(data, tag, arg);