VirtualBox

source: vbox/trunk/src/libs/curl-7.64.0/lib/setopt.c@ 94601

Last change on this file since 94601 was 85671, checked in by vboxsync, 4 years ago

Export out internal curl copy to make it a lot simpler to build VBox (OSE) on Windows. bugref:9814

  • Property svn:eol-style set to native
File size: 79.5 KB
Line 
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 1998 - 2019, Daniel Stenberg, <[email protected]>, et al.
9 *
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.haxx.se/docs/copyright.html.
13 *
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.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ***************************************************************************/
22
23#include "curl_setup.h"
24
25#include <limits.h>
26
27#ifdef HAVE_NETINET_IN_H
28#include <netinet/in.h>
29#endif
30
31#ifdef HAVE_LINUX_TCP_H
32#include <linux/tcp.h>
33#endif
34
35#include "urldata.h"
36#include "url.h"
37#include "progress.h"
38#include "content_encoding.h"
39#include "strcase.h"
40#include "share.h"
41#include "vtls/vtls.h"
42#include "warnless.h"
43#include "sendf.h"
44#include "http2.h"
45#include "setopt.h"
46#include "multiif.h"
47
48/* The last 3 #include files should be in this order */
49#include "curl_printf.h"
50#include "curl_memory.h"
51#include "memdebug.h"
52
53CURLcode Curl_setstropt(char **charp, const char *s)
54{
55 /* Release the previous storage at `charp' and replace by a dynamic storage
56 copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
57
58 Curl_safefree(*charp);
59
60 if(s) {
61 char *str = strdup(s);
62
63 if(!str)
64 return CURLE_OUT_OF_MEMORY;
65
66 *charp = str;
67 }
68
69 return CURLE_OK;
70}
71
72static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
73{
74 CURLcode result = CURLE_OK;
75 char *user = NULL;
76 char *passwd = NULL;
77
78 /* Parse the login details if specified. It not then we treat NULL as a hint
79 to clear the existing data */
80 if(option) {
81 result = Curl_parse_login_details(option, strlen(option),
82 (userp ? &user : NULL),
83 (passwdp ? &passwd : NULL),
84 NULL);
85 }
86
87 if(!result) {
88 /* Store the username part of option if required */
89 if(userp) {
90 if(!user && option && option[0] == ':') {
91 /* Allocate an empty string instead of returning NULL as user name */
92 user = strdup("");
93 if(!user)
94 result = CURLE_OUT_OF_MEMORY;
95 }
96
97 Curl_safefree(*userp);
98 *userp = user;
99 }
100
101 /* Store the password part of option if required */
102 if(passwdp) {
103 Curl_safefree(*passwdp);
104 *passwdp = passwd;
105 }
106 }
107
108 return result;
109}
110
111#define C_SSLVERSION_VALUE(x) (x & 0xffff)
112#define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
113
114CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
115 va_list param)
116{
117 char *argptr;
118 CURLcode result = CURLE_OK;
119 long arg;
120 curl_off_t bigsize;
121
122 switch(option) {
123 case CURLOPT_DNS_CACHE_TIMEOUT:
124 arg = va_arg(param, long);
125 if(arg < -1)
126 return CURLE_BAD_FUNCTION_ARGUMENT;
127 data->set.dns_cache_timeout = arg;
128 break;
129 case CURLOPT_DNS_USE_GLOBAL_CACHE:
130#if 0 /* deprecated */
131 /* remember we want this enabled */
132 arg = va_arg(param, long);
133 data->set.global_dns_cache = (0 != arg) ? TRUE : FALSE;
134#endif
135 break;
136 case CURLOPT_SSL_CIPHER_LIST:
137 /* set a list of cipher we want to use in the SSL connection */
138 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_ORIG],
139 va_arg(param, char *));
140 break;
141 case CURLOPT_PROXY_SSL_CIPHER_LIST:
142 /* set a list of cipher we want to use in the SSL connection for proxy */
143 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_PROXY],
144 va_arg(param, char *));
145 break;
146
147 case CURLOPT_TLS13_CIPHERS:
148 if(Curl_ssl_tls13_ciphersuites()) {
149 /* set preferred list of TLS 1.3 cipher suites */
150 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_ORIG],
151 va_arg(param, char *));
152 }
153 else
154 return CURLE_NOT_BUILT_IN;
155 break;
156 case CURLOPT_PROXY_TLS13_CIPHERS:
157 if(Curl_ssl_tls13_ciphersuites()) {
158 /* set preferred list of TLS 1.3 cipher suites for proxy */
159 result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY],
160 va_arg(param, char *));
161 }
162 else
163 return CURLE_NOT_BUILT_IN;
164 break;
165
166 case CURLOPT_RANDOM_FILE:
167 /*
168 * This is the path name to a file that contains random data to seed
169 * the random SSL stuff with. The file is only used for reading.
170 */
171 result = Curl_setstropt(&data->set.str[STRING_SSL_RANDOM_FILE],
172 va_arg(param, char *));
173 break;
174 case CURLOPT_EGDSOCKET:
175 /*
176 * The Entropy Gathering Daemon socket pathname
177 */
178 result = Curl_setstropt(&data->set.str[STRING_SSL_EGDSOCKET],
179 va_arg(param, char *));
180 break;
181 case CURLOPT_MAXCONNECTS:
182 /*
183 * Set the absolute number of maximum simultaneous alive connection that
184 * libcurl is allowed to have.
185 */
186 arg = va_arg(param, long);
187 if(arg < 0)
188 return CURLE_BAD_FUNCTION_ARGUMENT;
189 data->set.maxconnects = arg;
190 break;
191 case CURLOPT_FORBID_REUSE:
192 /*
193 * When this transfer is done, it must not be left to be reused by a
194 * subsequent transfer but shall be closed immediately.
195 */
196 data->set.reuse_forbid = (0 != va_arg(param, long)) ? TRUE : FALSE;
197 break;
198 case CURLOPT_FRESH_CONNECT:
199 /*
200 * This transfer shall not use a previously cached connection but
201 * should be made with a fresh new connect!
202 */
203 data->set.reuse_fresh = (0 != va_arg(param, long)) ? TRUE : FALSE;
204 break;
205 case CURLOPT_VERBOSE:
206 /*
207 * Verbose means infof() calls that give a lot of information about
208 * the connection and transfer procedures as well as internal choices.
209 */
210 data->set.verbose = (0 != va_arg(param, long)) ? TRUE : FALSE;
211 break;
212 case CURLOPT_HEADER:
213 /*
214 * Set to include the header in the general data output stream.
215 */
216 data->set.include_header = (0 != va_arg(param, long)) ? TRUE : FALSE;
217 break;
218 case CURLOPT_NOPROGRESS:
219 /*
220 * Shut off the internal supported progress meter
221 */
222 data->set.hide_progress = (0 != va_arg(param, long)) ? TRUE : FALSE;
223 if(data->set.hide_progress)
224 data->progress.flags |= PGRS_HIDE;
225 else
226 data->progress.flags &= ~PGRS_HIDE;
227 break;
228 case CURLOPT_NOBODY:
229 /*
230 * Do not include the body part in the output data stream.
231 */
232 data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE;
233 break;
234 case CURLOPT_FAILONERROR:
235 /*
236 * Don't output the >=400 error code HTML-page, but instead only
237 * return error.
238 */
239 data->set.http_fail_on_error = (0 != va_arg(param, long)) ? TRUE : FALSE;
240 break;
241 case CURLOPT_KEEP_SENDING_ON_ERROR:
242 data->set.http_keep_sending_on_error = (0 != va_arg(param, long)) ?
243 TRUE : FALSE;
244 break;
245 case CURLOPT_UPLOAD:
246 case CURLOPT_PUT:
247 /*
248 * We want to sent data to the remote host. If this is HTTP, that equals
249 * using the PUT request.
250 */
251 data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE;
252 if(data->set.upload) {
253 /* If this is HTTP, PUT is what's needed to "upload" */
254 data->set.httpreq = HTTPREQ_PUT;
255 data->set.opt_no_body = FALSE; /* this is implied */
256 }
257 else
258 /* In HTTP, the opposite of upload is GET (unless NOBODY is true as
259 then this can be changed to HEAD later on) */
260 data->set.httpreq = HTTPREQ_GET;
261 break;
262 case CURLOPT_REQUEST_TARGET:
263 result = Curl_setstropt(&data->set.str[STRING_TARGET],
264 va_arg(param, char *));
265 break;
266 case CURLOPT_FILETIME:
267 /*
268 * Try to get the file time of the remote document. The time will
269 * later (possibly) become available using curl_easy_getinfo().
270 */
271 data->set.get_filetime = (0 != va_arg(param, long)) ? TRUE : FALSE;
272 break;
273 case CURLOPT_FTP_CREATE_MISSING_DIRS:
274 /*
275 * An FTP option that modifies an upload to create missing directories on
276 * the server.
277 */
278 switch(va_arg(param, long)) {
279 case 0:
280 data->set.ftp_create_missing_dirs = 0;
281 break;
282 case 1:
283 data->set.ftp_create_missing_dirs = 1;
284 break;
285 case 2:
286 data->set.ftp_create_missing_dirs = 2;
287 break;
288 default:
289 /* reserve other values for future use */
290 result = CURLE_UNKNOWN_OPTION;
291 break;
292 }
293 break;
294 case CURLOPT_SERVER_RESPONSE_TIMEOUT:
295 /*
296 * Option that specifies how quickly an server response must be obtained
297 * before it is considered failure. For pingpong protocols.
298 */
299 arg = va_arg(param, long);
300 if((arg >= 0) && (arg <= (INT_MAX/1000)))
301 data->set.server_response_timeout = arg * 1000;
302 else
303 return CURLE_BAD_FUNCTION_ARGUMENT;
304 break;
305 case CURLOPT_TFTP_NO_OPTIONS:
306 /*
307 * Option that prevents libcurl from sending TFTP option requests to the
308 * server.
309 */
310 data->set.tftp_no_options = va_arg(param, long) != 0;
311 break;
312 case CURLOPT_TFTP_BLKSIZE:
313 /*
314 * TFTP option that specifies the block size to use for data transmission.
315 */
316 arg = va_arg(param, long);
317 if(arg < 0)
318 return CURLE_BAD_FUNCTION_ARGUMENT;
319 data->set.tftp_blksize = arg;
320 break;
321 case CURLOPT_DIRLISTONLY:
322 /*
323 * An option that changes the command to one that asks for a list
324 * only, no file info details.
325 */
326 data->set.ftp_list_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
327 break;
328 case CURLOPT_APPEND:
329 /*
330 * We want to upload and append to an existing file.
331 */
332 data->set.ftp_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
333 break;
334 case CURLOPT_FTP_FILEMETHOD:
335 /*
336 * How do access files over FTP.
337 */
338 arg = va_arg(param, long);
339 if((arg < CURLFTPMETHOD_DEFAULT) || (arg > CURLFTPMETHOD_SINGLECWD))
340 return CURLE_BAD_FUNCTION_ARGUMENT;
341 data->set.ftp_filemethod = (curl_ftpfile)arg;
342 break;
343 case CURLOPT_NETRC:
344 /*
345 * Parse the $HOME/.netrc file
346 */
347 arg = va_arg(param, long);
348 if((arg < CURL_NETRC_IGNORED) || (arg > CURL_NETRC_REQUIRED))
349 return CURLE_BAD_FUNCTION_ARGUMENT;
350 data->set.use_netrc = (enum CURL_NETRC_OPTION)arg;
351 break;
352 case CURLOPT_NETRC_FILE:
353 /*
354 * Use this file instead of the $HOME/.netrc file
355 */
356 result = Curl_setstropt(&data->set.str[STRING_NETRC_FILE],
357 va_arg(param, char *));
358 break;
359 case CURLOPT_TRANSFERTEXT:
360 /*
361 * This option was previously named 'FTPASCII'. Renamed to work with
362 * more protocols than merely FTP.
363 *
364 * Transfer using ASCII (instead of BINARY).
365 */
366 data->set.prefer_ascii = (0 != va_arg(param, long)) ? TRUE : FALSE;
367 break;
368 case CURLOPT_TIMECONDITION:
369 /*
370 * Set HTTP time condition. This must be one of the defines in the
371 * curl/curl.h header file.
372 */
373 arg = va_arg(param, long);
374 if((arg < CURL_TIMECOND_NONE) || (arg > CURL_TIMECOND_LASTMOD))
375 return CURLE_BAD_FUNCTION_ARGUMENT;
376 data->set.timecondition = (curl_TimeCond)arg;
377 break;
378 case CURLOPT_TIMEVALUE:
379 /*
380 * This is the value to compare with the remote document with the
381 * method set with CURLOPT_TIMECONDITION
382 */
383 data->set.timevalue = (time_t)va_arg(param, long);
384 break;
385
386 case CURLOPT_TIMEVALUE_LARGE:
387 /*
388 * This is the value to compare with the remote document with the
389 * method set with CURLOPT_TIMECONDITION
390 */
391 data->set.timevalue = (time_t)va_arg(param, curl_off_t);
392 break;
393
394 case CURLOPT_SSLVERSION:
395 case CURLOPT_PROXY_SSLVERSION:
396 /*
397 * Set explicit SSL version to try to connect with, as some SSL
398 * implementations are lame.
399 */
400#ifdef USE_SSL
401 {
402 long version, version_max;
403 struct ssl_primary_config *primary = (option == CURLOPT_SSLVERSION ?
404 &data->set.ssl.primary :
405 &data->set.proxy_ssl.primary);
406
407 arg = va_arg(param, long);
408
409 version = C_SSLVERSION_VALUE(arg);
410 version_max = C_SSLVERSION_MAX_VALUE(arg);
411
412 if(version < CURL_SSLVERSION_DEFAULT ||
413 version >= CURL_SSLVERSION_LAST ||
414 version_max < CURL_SSLVERSION_MAX_NONE ||
415 version_max >= CURL_SSLVERSION_MAX_LAST)
416 return CURLE_BAD_FUNCTION_ARGUMENT;
417
418 primary->version = version;
419 primary->version_max = version_max;
420 }
421#else
422 result = CURLE_UNKNOWN_OPTION;
423#endif
424 break;
425
426#ifndef CURL_DISABLE_HTTP
427 case CURLOPT_AUTOREFERER:
428 /*
429 * Switch on automatic referer that gets set if curl follows locations.
430 */
431 data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
432 break;
433
434 case CURLOPT_ACCEPT_ENCODING:
435 /*
436 * String to use at the value of Accept-Encoding header.
437 *
438 * If the encoding is set to "" we use an Accept-Encoding header that
439 * encompasses all the encodings we support.
440 * If the encoding is set to NULL we don't send an Accept-Encoding header
441 * and ignore an received Content-Encoding header.
442 *
443 */
444 argptr = va_arg(param, char *);
445 if(argptr && !*argptr) {
446 argptr = Curl_all_content_encodings();
447 if(!argptr)
448 result = CURLE_OUT_OF_MEMORY;
449 else {
450 result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
451 free(argptr);
452 }
453 }
454 else
455 result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
456 break;
457
458 case CURLOPT_TRANSFER_ENCODING:
459 data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
460 TRUE : FALSE;
461 break;
462
463 case CURLOPT_FOLLOWLOCATION:
464 /*
465 * Follow Location: header hints on a HTTP-server.
466 */
467 data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
468 break;
469
470 case CURLOPT_UNRESTRICTED_AUTH:
471 /*
472 * Send authentication (user+password) when following locations, even when
473 * hostname changed.
474 */
475 data->set.allow_auth_to_other_hosts =
476 (0 != va_arg(param, long)) ? TRUE : FALSE;
477 break;
478
479 case CURLOPT_MAXREDIRS:
480 /*
481 * The maximum amount of hops you allow curl to follow Location:
482 * headers. This should mostly be used to detect never-ending loops.
483 */
484 arg = va_arg(param, long);
485 if(arg < -1)
486 return CURLE_BAD_FUNCTION_ARGUMENT;
487 data->set.maxredirs = arg;
488 break;
489
490 case CURLOPT_POSTREDIR:
491 /*
492 * Set the behaviour of POST when redirecting
493 * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
494 * CURL_REDIR_POST_301 - POST is kept as POST after 301
495 * CURL_REDIR_POST_302 - POST is kept as POST after 302
496 * CURL_REDIR_POST_303 - POST is kept as POST after 303
497 * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
498 * other - POST is kept as POST after 301 and 302
499 */
500 arg = va_arg(param, long);
501 if(arg < CURL_REDIR_GET_ALL)
502 /* no return error on too high numbers since the bitmask could be
503 extended in a future */
504 return CURLE_BAD_FUNCTION_ARGUMENT;
505 data->set.keep_post = arg & CURL_REDIR_POST_ALL;
506 break;
507
508 case CURLOPT_POST:
509 /* Does this option serve a purpose anymore? Yes it does, when
510 CURLOPT_POSTFIELDS isn't used and the POST data is read off the
511 callback! */
512 if(va_arg(param, long)) {
513 data->set.httpreq = HTTPREQ_POST;
514 data->set.opt_no_body = FALSE; /* this is implied */
515 }
516 else
517 data->set.httpreq = HTTPREQ_GET;
518 break;
519
520 case CURLOPT_COPYPOSTFIELDS:
521 /*
522 * A string with POST data. Makes curl HTTP POST. Even if it is NULL.
523 * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
524 * CURLOPT_COPYPOSTFIELDS and not altered later.
525 */
526 argptr = va_arg(param, char *);
527
528 if(!argptr || data->set.postfieldsize == -1)
529 result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
530 else {
531 /*
532 * Check that requested length does not overflow the size_t type.
533 */
534
535 if((data->set.postfieldsize < 0) ||
536 ((sizeof(curl_off_t) != sizeof(size_t)) &&
537 (data->set.postfieldsize > (curl_off_t)((size_t)-1))))
538 result = CURLE_OUT_OF_MEMORY;
539 else {
540 char *p;
541
542 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
543
544 /* Allocate even when size == 0. This satisfies the need of possible
545 later address compare to detect the COPYPOSTFIELDS mode, and
546 to mark that postfields is used rather than read function or
547 form data.
548 */
549 p = malloc((size_t)(data->set.postfieldsize?
550 data->set.postfieldsize:1));
551
552 if(!p)
553 result = CURLE_OUT_OF_MEMORY;
554 else {
555 if(data->set.postfieldsize)
556 memcpy(p, argptr, (size_t)data->set.postfieldsize);
557
558 data->set.str[STRING_COPYPOSTFIELDS] = p;
559 }
560 }
561 }
562
563 data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
564 data->set.httpreq = HTTPREQ_POST;
565 break;
566
567 case CURLOPT_POSTFIELDS:
568 /*
569 * Like above, but use static data instead of copying it.
570 */
571 data->set.postfields = va_arg(param, void *);
572 /* Release old copied data. */
573 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
574 data->set.httpreq = HTTPREQ_POST;
575 break;
576
577 case CURLOPT_POSTFIELDSIZE:
578 /*
579 * The size of the POSTFIELD data to prevent libcurl to do strlen() to
580 * figure it out. Enables binary posts.
581 */
582 bigsize = va_arg(param, long);
583 if(bigsize < -1)
584 return CURLE_BAD_FUNCTION_ARGUMENT;
585
586 if(data->set.postfieldsize < bigsize &&
587 data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
588 /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
589 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
590 data->set.postfields = NULL;
591 }
592
593 data->set.postfieldsize = bigsize;
594 break;
595
596 case CURLOPT_POSTFIELDSIZE_LARGE:
597 /*
598 * The size of the POSTFIELD data to prevent libcurl to do strlen() to
599 * figure it out. Enables binary posts.
600 */
601 bigsize = va_arg(param, curl_off_t);
602 if(bigsize < -1)
603 return CURLE_BAD_FUNCTION_ARGUMENT;
604
605 if(data->set.postfieldsize < bigsize &&
606 data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
607 /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
608 (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
609 data->set.postfields = NULL;
610 }
611
612 data->set.postfieldsize = bigsize;
613 break;
614
615 case CURLOPT_HTTPPOST:
616 /*
617 * Set to make us do HTTP POST
618 */
619 data->set.httppost = va_arg(param, struct curl_httppost *);
620 data->set.httpreq = HTTPREQ_POST_FORM;
621 data->set.opt_no_body = FALSE; /* this is implied */
622 break;
623#endif /* CURL_DISABLE_HTTP */
624
625 case CURLOPT_MIMEPOST:
626 /*
627 * Set to make us do MIME/form POST
628 */
629 result = Curl_mime_set_subparts(&data->set.mimepost,
630 va_arg(param, curl_mime *), FALSE);
631 if(!result) {
632 data->set.httpreq = HTTPREQ_POST_MIME;
633 data->set.opt_no_body = FALSE; /* this is implied */
634 }
635 break;
636
637 case CURLOPT_REFERER:
638 /*
639 * String to set in the HTTP Referer: field.
640 */
641 if(data->change.referer_alloc) {
642 Curl_safefree(data->change.referer);
643 data->change.referer_alloc = FALSE;
644 }
645 result = Curl_setstropt(&data->set.str[STRING_SET_REFERER],
646 va_arg(param, char *));
647 data->change.referer = data->set.str[STRING_SET_REFERER];
648 break;
649
650 case CURLOPT_USERAGENT:
651 /*
652 * String to use in the HTTP User-Agent field
653 */
654 result = Curl_setstropt(&data->set.str[STRING_USERAGENT],
655 va_arg(param, char *));
656 break;
657
658 case CURLOPT_HTTPHEADER:
659 /*
660 * Set a list with HTTP headers to use (or replace internals with)
661 */
662 data->set.headers = va_arg(param, struct curl_slist *);
663 break;
664
665#ifndef CURL_DISABLE_HTTP
666 case CURLOPT_PROXYHEADER:
667 /*
668 * Set a list with proxy headers to use (or replace internals with)
669 *
670 * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a
671 * long time we remain doing it this way until CURLOPT_PROXYHEADER is
672 * used. As soon as this option has been used, if set to anything but
673 * NULL, custom headers for proxies are only picked from this list.
674 *
675 * Set this option to NULL to restore the previous behavior.
676 */
677 data->set.proxyheaders = va_arg(param, struct curl_slist *);
678 break;
679
680 case CURLOPT_HEADEROPT:
681 /*
682 * Set header option.
683 */
684 arg = va_arg(param, long);
685 data->set.sep_headers = (arg & CURLHEADER_SEPARATE)? TRUE: FALSE;
686 break;
687
688 case CURLOPT_HTTP200ALIASES:
689 /*
690 * Set a list of aliases for HTTP 200 in response header
691 */
692 data->set.http200aliases = va_arg(param, struct curl_slist *);
693 break;
694
695#if !defined(CURL_DISABLE_COOKIES)
696 case CURLOPT_COOKIE:
697 /*
698 * Cookie string to send to the remote server in the request.
699 */
700 result = Curl_setstropt(&data->set.str[STRING_COOKIE],
701 va_arg(param, char *));
702 break;
703
704 case CURLOPT_COOKIEFILE:
705 /*
706 * Set cookie file to read and parse. Can be used multiple times.
707 */
708 argptr = (char *)va_arg(param, void *);
709 if(argptr) {
710 struct curl_slist *cl;
711 /* append the cookie file name to the list of file names, and deal with
712 them later */
713 cl = curl_slist_append(data->change.cookielist, argptr);
714 if(!cl) {
715 curl_slist_free_all(data->change.cookielist);
716 data->change.cookielist = NULL;
717 return CURLE_OUT_OF_MEMORY;
718 }
719 data->change.cookielist = cl; /* store the list for later use */
720 }
721 break;
722
723 case CURLOPT_COOKIEJAR:
724 /*
725 * Set cookie file name to dump all cookies to when we're done.
726 */
727 {
728 struct CookieInfo *newcookies;
729 result = Curl_setstropt(&data->set.str[STRING_COOKIEJAR],
730 va_arg(param, char *));
731
732 /*
733 * Activate the cookie parser. This may or may not already
734 * have been made.
735 */
736 newcookies = Curl_cookie_init(data, NULL, data->cookies,
737 data->set.cookiesession);
738 if(!newcookies)
739 result = CURLE_OUT_OF_MEMORY;
740 data->cookies = newcookies;
741 }
742 break;
743
744 case CURLOPT_COOKIESESSION:
745 /*
746 * Set this option to TRUE to start a new "cookie session". It will
747 * prevent the forthcoming read-cookies-from-file actions to accept
748 * cookies that are marked as being session cookies, as they belong to a
749 * previous session.
750 *
751 * In the original Netscape cookie spec, "session cookies" are cookies
752 * with no expire date set. RFC2109 describes the same action if no
753 * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds
754 * a 'Discard' action that can enforce the discard even for cookies that
755 * have a Max-Age.
756 *
757 * We run mostly with the original cookie spec, as hardly anyone implements
758 * anything else.
759 */
760 data->set.cookiesession = (0 != va_arg(param, long)) ? TRUE : FALSE;
761 break;
762
763 case CURLOPT_COOKIELIST:
764 argptr = va_arg(param, char *);
765
766 if(argptr == NULL)
767 break;
768
769 if(strcasecompare(argptr, "ALL")) {
770 /* clear all cookies */
771 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
772 Curl_cookie_clearall(data->cookies);
773 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
774 }
775 else if(strcasecompare(argptr, "SESS")) {
776 /* clear session cookies */
777 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
778 Curl_cookie_clearsess(data->cookies);
779 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
780 }
781 else if(strcasecompare(argptr, "FLUSH")) {
782 /* flush cookies to file, takes care of the locking */
783 Curl_flush_cookies(data, 0);
784 }
785 else if(strcasecompare(argptr, "RELOAD")) {
786 /* reload cookies from file */
787 Curl_cookie_loadfiles(data);
788 break;
789 }
790 else {
791 if(!data->cookies)
792 /* if cookie engine was not running, activate it */
793 data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
794
795 argptr = strdup(argptr);
796 if(!argptr || !data->cookies) {
797 result = CURLE_OUT_OF_MEMORY;
798 free(argptr);
799 }
800 else {
801 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
802
803 if(checkprefix("Set-Cookie:", argptr))
804 /* HTTP Header format line */
805 Curl_cookie_add(data, data->cookies, TRUE, FALSE, argptr + 11, NULL,
806 NULL, TRUE);
807
808 else
809 /* Netscape format line */
810 Curl_cookie_add(data, data->cookies, FALSE, FALSE, argptr, NULL,
811 NULL, TRUE);
812
813 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
814 free(argptr);
815 }
816 }
817
818 break;
819#endif /* !CURL_DISABLE_COOKIES */
820
821 case CURLOPT_HTTPGET:
822 /*
823 * Set to force us do HTTP GET
824 */
825 if(va_arg(param, long)) {
826 data->set.httpreq = HTTPREQ_GET;
827 data->set.upload = FALSE; /* switch off upload */
828 data->set.opt_no_body = FALSE; /* this is implied */
829 }
830 break;
831
832 case CURLOPT_HTTP_VERSION:
833 /*
834 * This sets a requested HTTP version to be used. The value is one of
835 * the listed enums in curl/curl.h.
836 */
837 arg = va_arg(param, long);
838 if(arg < CURL_HTTP_VERSION_NONE)
839 return CURLE_BAD_FUNCTION_ARGUMENT;
840#ifndef USE_NGHTTP2
841 if(arg >= CURL_HTTP_VERSION_2)
842 return CURLE_UNSUPPORTED_PROTOCOL;
843#else
844 if(arg > CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE)
845 return CURLE_UNSUPPORTED_PROTOCOL;
846 if(arg == CURL_HTTP_VERSION_NONE)
847 arg = CURL_HTTP_VERSION_2TLS;
848#endif
849 data->set.httpversion = arg;
850 break;
851
852 case CURLOPT_EXPECT_100_TIMEOUT_MS:
853 /*
854 * Time to wait for a response to a HTTP request containing an
855 * Expect: 100-continue header before sending the data anyway.
856 */
857 arg = va_arg(param, long);
858 if(arg < 0)
859 return CURLE_BAD_FUNCTION_ARGUMENT;
860 data->set.expect_100_timeout = arg;
861 break;
862
863 case CURLOPT_HTTP09_ALLOWED:
864 arg = va_arg(param, unsigned long);
865 if(arg > 1L)
866 return CURLE_BAD_FUNCTION_ARGUMENT;
867 data->set.http09_allowed = arg ? TRUE : FALSE;
868 break;
869#endif /* CURL_DISABLE_HTTP */
870
871 case CURLOPT_HTTPAUTH:
872 /*
873 * Set HTTP Authentication type BITMASK.
874 */
875 {
876 int bitcheck;
877 bool authbits;
878 unsigned long auth = va_arg(param, unsigned long);
879
880 if(auth == CURLAUTH_NONE) {
881 data->set.httpauth = auth;
882 break;
883 }
884
885 /* the DIGEST_IE bit is only used to set a special marker, for all the
886 rest we need to handle it as normal DIGEST */
887 data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
888
889 if(auth & CURLAUTH_DIGEST_IE) {
890 auth |= CURLAUTH_DIGEST; /* set standard digest bit */
891 auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
892 }
893
894 /* switch off bits we can't support */
895#ifndef USE_NTLM
896 auth &= ~CURLAUTH_NTLM; /* no NTLM support */
897 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
898#elif !defined(NTLM_WB_ENABLED)
899 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
900#endif
901#ifndef USE_SPNEGO
902 auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
903 GSS-API or SSPI */
904#endif
905
906 /* check if any auth bit lower than CURLAUTH_ONLY is still set */
907 bitcheck = 0;
908 authbits = FALSE;
909 while(bitcheck < 31) {
910 if(auth & (1UL << bitcheck++)) {
911 authbits = TRUE;
912 break;
913 }
914 }
915 if(!authbits)
916 return CURLE_NOT_BUILT_IN; /* no supported types left! */
917
918 data->set.httpauth = auth;
919 }
920 break;
921
922 case CURLOPT_CUSTOMREQUEST:
923 /*
924 * Set a custom string to use as request
925 */
926 result = Curl_setstropt(&data->set.str[STRING_CUSTOMREQUEST],
927 va_arg(param, char *));
928
929 /* we don't set
930 data->set.httpreq = HTTPREQ_CUSTOM;
931 here, we continue as if we were using the already set type
932 and this just changes the actual request keyword */
933 break;
934
935#ifndef CURL_DISABLE_PROXY
936 case CURLOPT_HTTPPROXYTUNNEL:
937 /*
938 * Tunnel operations through the proxy instead of normal proxy use
939 */
940 data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long)) ?
941 TRUE : FALSE;
942 break;
943
944 case CURLOPT_PROXYPORT:
945 /*
946 * Explicitly set HTTP proxy port number.
947 */
948 arg = va_arg(param, long);
949 if((arg < 0) || (arg > 65535))
950 return CURLE_BAD_FUNCTION_ARGUMENT;
951 data->set.proxyport = arg;
952 break;
953
954 case CURLOPT_PROXYAUTH:
955 /*
956 * Set HTTP Authentication type BITMASK.
957 */
958 {
959 int bitcheck;
960 bool authbits;
961 unsigned long auth = va_arg(param, unsigned long);
962
963 if(auth == CURLAUTH_NONE) {
964 data->set.proxyauth = auth;
965 break;
966 }
967
968 /* the DIGEST_IE bit is only used to set a special marker, for all the
969 rest we need to handle it as normal DIGEST */
970 data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
971
972 if(auth & CURLAUTH_DIGEST_IE) {
973 auth |= CURLAUTH_DIGEST; /* set standard digest bit */
974 auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
975 }
976 /* switch off bits we can't support */
977#ifndef USE_NTLM
978 auth &= ~CURLAUTH_NTLM; /* no NTLM support */
979 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
980#elif !defined(NTLM_WB_ENABLED)
981 auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
982#endif
983#ifndef USE_SPNEGO
984 auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
985 GSS-API or SSPI */
986#endif
987
988 /* check if any auth bit lower than CURLAUTH_ONLY is still set */
989 bitcheck = 0;
990 authbits = FALSE;
991 while(bitcheck < 31) {
992 if(auth & (1UL << bitcheck++)) {
993 authbits = TRUE;
994 break;
995 }
996 }
997 if(!authbits)
998 return CURLE_NOT_BUILT_IN; /* no supported types left! */
999
1000 data->set.proxyauth = auth;
1001 }
1002 break;
1003
1004 case CURLOPT_PROXY:
1005 /*
1006 * Set proxy server:port to use as proxy.
1007 *
1008 * If the proxy is set to "" (and CURLOPT_SOCKS_PROXY is set to "" or NULL)
1009 * we explicitly say that we don't want to use a proxy
1010 * (even though there might be environment variables saying so).
1011 *
1012 * Setting it to NULL, means no proxy but allows the environment variables
1013 * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
1014 */
1015 result = Curl_setstropt(&data->set.str[STRING_PROXY],
1016 va_arg(param, char *));
1017 break;
1018
1019 case CURLOPT_PRE_PROXY:
1020 /*
1021 * Set proxy server:port to use as SOCKS proxy.
1022 *
1023 * If the proxy is set to "" or NULL we explicitly say that we don't want
1024 * to use the socks proxy.
1025 */
1026 result = Curl_setstropt(&data->set.str[STRING_PRE_PROXY],
1027 va_arg(param, char *));
1028 break;
1029
1030 case CURLOPT_PROXYTYPE:
1031 /*
1032 * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
1033 */
1034 arg = va_arg(param, long);
1035 if((arg < CURLPROXY_HTTP) || (arg > CURLPROXY_SOCKS5_HOSTNAME))
1036 return CURLE_BAD_FUNCTION_ARGUMENT;
1037 data->set.proxytype = (curl_proxytype)arg;
1038 break;
1039
1040 case CURLOPT_PROXY_TRANSFER_MODE:
1041 /*
1042 * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
1043 */
1044 switch(va_arg(param, long)) {
1045 case 0:
1046 data->set.proxy_transfer_mode = FALSE;
1047 break;
1048 case 1:
1049 data->set.proxy_transfer_mode = TRUE;
1050 break;
1051 default:
1052 /* reserve other values for future use */
1053 result = CURLE_UNKNOWN_OPTION;
1054 break;
1055 }
1056 break;
1057#endif /* CURL_DISABLE_PROXY */
1058
1059 case CURLOPT_SOCKS5_AUTH:
1060 data->set.socks5auth = va_arg(param, unsigned long);
1061 if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
1062 result = CURLE_NOT_BUILT_IN;
1063 break;
1064#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1065 case CURLOPT_SOCKS5_GSSAPI_NEC:
1066 /*
1067 * Set flag for NEC SOCK5 support
1068 */
1069 data->set.socks5_gssapi_nec = (0 != va_arg(param, long)) ? TRUE : FALSE;
1070 break;
1071#endif
1072
1073 case CURLOPT_SOCKS5_GSSAPI_SERVICE:
1074 case CURLOPT_PROXY_SERVICE_NAME:
1075 /*
1076 * Set proxy authentication service name for Kerberos 5 and SPNEGO
1077 */
1078 result = Curl_setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME],
1079 va_arg(param, char *));
1080 break;
1081
1082 case CURLOPT_SERVICE_NAME:
1083 /*
1084 * Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO
1085 */
1086 result = Curl_setstropt(&data->set.str[STRING_SERVICE_NAME],
1087 va_arg(param, char *));
1088 break;
1089
1090 case CURLOPT_HEADERDATA:
1091 /*
1092 * Custom pointer to pass the header write callback function
1093 */
1094 data->set.writeheader = (void *)va_arg(param, void *);
1095 break;
1096 case CURLOPT_ERRORBUFFER:
1097 /*
1098 * Error buffer provided by the caller to get the human readable
1099 * error string in.
1100 */
1101 data->set.errorbuffer = va_arg(param, char *);
1102 break;
1103 case CURLOPT_WRITEDATA:
1104 /*
1105 * FILE pointer to write to. Or possibly
1106 * used as argument to the write callback.
1107 */
1108 data->set.out = va_arg(param, void *);
1109 break;
1110 case CURLOPT_FTPPORT:
1111 /*
1112 * Use FTP PORT, this also specifies which IP address to use
1113 */
1114 result = Curl_setstropt(&data->set.str[STRING_FTPPORT],
1115 va_arg(param, char *));
1116 data->set.ftp_use_port = (data->set.str[STRING_FTPPORT]) ? TRUE : FALSE;
1117 break;
1118
1119 case CURLOPT_FTP_USE_EPRT:
1120 data->set.ftp_use_eprt = (0 != va_arg(param, long)) ? TRUE : FALSE;
1121 break;
1122
1123 case CURLOPT_FTP_USE_EPSV:
1124 data->set.ftp_use_epsv = (0 != va_arg(param, long)) ? TRUE : FALSE;
1125 break;
1126
1127 case CURLOPT_FTP_USE_PRET:
1128 data->set.ftp_use_pret = (0 != va_arg(param, long)) ? TRUE : FALSE;
1129 break;
1130
1131 case CURLOPT_FTP_SSL_CCC:
1132 arg = va_arg(param, long);
1133 if((arg < CURLFTPSSL_CCC_NONE) || (arg > CURLFTPSSL_CCC_ACTIVE))
1134 return CURLE_BAD_FUNCTION_ARGUMENT;
1135 data->set.ftp_ccc = (curl_ftpccc)arg;
1136 break;
1137
1138 case CURLOPT_FTP_SKIP_PASV_IP:
1139 /*
1140 * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
1141 * bypass of the IP address in PASV responses.
1142 */
1143 data->set.ftp_skip_ip = (0 != va_arg(param, long)) ? TRUE : FALSE;
1144 break;
1145
1146 case CURLOPT_READDATA:
1147 /*
1148 * FILE pointer to read the file to be uploaded from. Or possibly
1149 * used as argument to the read callback.
1150 */
1151 data->set.in_set = va_arg(param, void *);
1152 break;
1153 case CURLOPT_INFILESIZE:
1154 /*
1155 * If known, this should inform curl about the file size of the
1156 * to-be-uploaded file.
1157 */
1158 arg = va_arg(param, long);
1159 if(arg < -1)
1160 return CURLE_BAD_FUNCTION_ARGUMENT;
1161 data->set.filesize = arg;
1162 break;
1163 case CURLOPT_INFILESIZE_LARGE:
1164 /*
1165 * If known, this should inform curl about the file size of the
1166 * to-be-uploaded file.
1167 */
1168 bigsize = va_arg(param, curl_off_t);
1169 if(bigsize < -1)
1170 return CURLE_BAD_FUNCTION_ARGUMENT;
1171 data->set.filesize = bigsize;
1172 break;
1173 case CURLOPT_LOW_SPEED_LIMIT:
1174 /*
1175 * The low speed limit that if transfers are below this for
1176 * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
1177 */
1178 arg = va_arg(param, long);
1179 if(arg < 0)
1180 return CURLE_BAD_FUNCTION_ARGUMENT;
1181 data->set.low_speed_limit = arg;
1182 break;
1183 case CURLOPT_MAX_SEND_SPEED_LARGE:
1184 /*
1185 * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
1186 * bytes per second the transfer is throttled..
1187 */
1188 bigsize = va_arg(param, curl_off_t);
1189 if(bigsize < 0)
1190 return CURLE_BAD_FUNCTION_ARGUMENT;
1191 data->set.max_send_speed = bigsize;
1192 break;
1193 case CURLOPT_MAX_RECV_SPEED_LARGE:
1194 /*
1195 * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
1196 * second the transfer is throttled..
1197 */
1198 bigsize = va_arg(param, curl_off_t);
1199 if(bigsize < 0)
1200 return CURLE_BAD_FUNCTION_ARGUMENT;
1201 data->set.max_recv_speed = bigsize;
1202 break;
1203 case CURLOPT_LOW_SPEED_TIME:
1204 /*
1205 * The low speed time that if transfers are below the set
1206 * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
1207 */
1208 arg = va_arg(param, long);
1209 if(arg < 0)
1210 return CURLE_BAD_FUNCTION_ARGUMENT;
1211 data->set.low_speed_time = arg;
1212 break;
1213 case CURLOPT_CURLU:
1214 /*
1215 * pass CURLU to set URL
1216 */
1217 data->set.uh = va_arg(param, CURLU *);
1218 break;
1219 case CURLOPT_URL:
1220 /*
1221 * The URL to fetch.
1222 */
1223 if(data->change.url_alloc) {
1224 /* the already set URL is allocated, free it first! */
1225 Curl_safefree(data->change.url);
1226 data->change.url_alloc = FALSE;
1227 }
1228 result = Curl_setstropt(&data->set.str[STRING_SET_URL],
1229 va_arg(param, char *));
1230 data->change.url = data->set.str[STRING_SET_URL];
1231 break;
1232 case CURLOPT_PORT:
1233 /*
1234 * The port number to use when getting the URL
1235 */
1236 arg = va_arg(param, long);
1237 if((arg < 0) || (arg > 65535))
1238 return CURLE_BAD_FUNCTION_ARGUMENT;
1239 data->set.use_port = arg;
1240 break;
1241 case CURLOPT_TIMEOUT:
1242 /*
1243 * The maximum time you allow curl to use for a single transfer
1244 * operation.
1245 */
1246 arg = va_arg(param, long);
1247 if((arg >= 0) && (arg <= (INT_MAX/1000)))
1248 data->set.timeout = arg * 1000;
1249 else
1250 return CURLE_BAD_FUNCTION_ARGUMENT;
1251 break;
1252
1253 case CURLOPT_TIMEOUT_MS:
1254 arg = va_arg(param, long);
1255 if(arg < 0)
1256 return CURLE_BAD_FUNCTION_ARGUMENT;
1257 data->set.timeout = arg;
1258 break;
1259
1260 case CURLOPT_CONNECTTIMEOUT:
1261 /*
1262 * The maximum time you allow curl to use to connect.
1263 */
1264 arg = va_arg(param, long);
1265 if((arg >= 0) && (arg <= (INT_MAX/1000)))
1266 data->set.connecttimeout = arg * 1000;
1267 else
1268 return CURLE_BAD_FUNCTION_ARGUMENT;
1269 break;
1270
1271 case CURLOPT_CONNECTTIMEOUT_MS:
1272 arg = va_arg(param, long);
1273 if(arg < 0)
1274 return CURLE_BAD_FUNCTION_ARGUMENT;
1275 data->set.connecttimeout = arg;
1276 break;
1277
1278 case CURLOPT_ACCEPTTIMEOUT_MS:
1279 /*
1280 * The maximum time you allow curl to wait for server connect
1281 */
1282 arg = va_arg(param, long);
1283 if(arg < 0)
1284 return CURLE_BAD_FUNCTION_ARGUMENT;
1285 data->set.accepttimeout = arg;
1286 break;
1287
1288 case CURLOPT_USERPWD:
1289 /*
1290 * user:password to use in the operation
1291 */
1292 result = setstropt_userpwd(va_arg(param, char *),
1293 &data->set.str[STRING_USERNAME],
1294 &data->set.str[STRING_PASSWORD]);
1295 break;
1296
1297 case CURLOPT_USERNAME:
1298 /*
1299 * authentication user name to use in the operation
1300 */
1301 result = Curl_setstropt(&data->set.str[STRING_USERNAME],
1302 va_arg(param, char *));
1303 break;
1304
1305 case CURLOPT_PASSWORD:
1306 /*
1307 * authentication password to use in the operation
1308 */
1309 result = Curl_setstropt(&data->set.str[STRING_PASSWORD],
1310 va_arg(param, char *));
1311 break;
1312
1313 case CURLOPT_LOGIN_OPTIONS:
1314 /*
1315 * authentication options to use in the operation
1316 */
1317 result = Curl_setstropt(&data->set.str[STRING_OPTIONS],
1318 va_arg(param, char *));
1319 break;
1320
1321 case CURLOPT_XOAUTH2_BEARER:
1322 /*
1323 * OAuth 2.0 bearer token to use in the operation
1324 */
1325 result = Curl_setstropt(&data->set.str[STRING_BEARER],
1326 va_arg(param, char *));
1327 break;
1328
1329 case CURLOPT_POSTQUOTE:
1330 /*
1331 * List of RAW FTP commands to use after a transfer
1332 */
1333 data->set.postquote = va_arg(param, struct curl_slist *);
1334 break;
1335 case CURLOPT_PREQUOTE:
1336 /*
1337 * List of RAW FTP commands to use prior to RETR (Wesley Laxton)
1338 */
1339 data->set.prequote = va_arg(param, struct curl_slist *);
1340 break;
1341 case CURLOPT_QUOTE:
1342 /*
1343 * List of RAW FTP commands to use before a transfer
1344 */
1345 data->set.quote = va_arg(param, struct curl_slist *);
1346 break;
1347 case CURLOPT_RESOLVE:
1348 /*
1349 * List of NAME:[address] names to populate the DNS cache with
1350 * Prefix the NAME with dash (-) to _remove_ the name from the cache.
1351 *
1352 * Names added with this API will remain in the cache until explicitly
1353 * removed or the handle is cleaned up.
1354 *
1355 * This API can remove any name from the DNS cache, but only entries
1356 * that aren't actually in use right now will be pruned immediately.
1357 */
1358 data->set.resolve = va_arg(param, struct curl_slist *);
1359 data->change.resolve = data->set.resolve;
1360 break;
1361 case CURLOPT_PROGRESSFUNCTION:
1362 /*
1363 * Progress callback function
1364 */
1365 data->set.fprogress = va_arg(param, curl_progress_callback);
1366 if(data->set.fprogress)
1367 data->progress.callback = TRUE; /* no longer internal */
1368 else
1369 data->progress.callback = FALSE; /* NULL enforces internal */
1370 break;
1371
1372 case CURLOPT_XFERINFOFUNCTION:
1373 /*
1374 * Transfer info callback function
1375 */
1376 data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);
1377 if(data->set.fxferinfo)
1378 data->progress.callback = TRUE; /* no longer internal */
1379 else
1380 data->progress.callback = FALSE; /* NULL enforces internal */
1381
1382 break;
1383
1384 case CURLOPT_PROGRESSDATA:
1385 /*
1386 * Custom client data to pass to the progress callback
1387 */
1388 data->set.progress_client = va_arg(param, void *);
1389 break;
1390
1391#ifndef CURL_DISABLE_PROXY
1392 case CURLOPT_PROXYUSERPWD:
1393 /*
1394 * user:password needed to use the proxy
1395 */
1396 result = setstropt_userpwd(va_arg(param, char *),
1397 &data->set.str[STRING_PROXYUSERNAME],
1398 &data->set.str[STRING_PROXYPASSWORD]);
1399 break;
1400 case CURLOPT_PROXYUSERNAME:
1401 /*
1402 * authentication user name to use in the operation
1403 */
1404 result = Curl_setstropt(&data->set.str[STRING_PROXYUSERNAME],
1405 va_arg(param, char *));
1406 break;
1407 case CURLOPT_PROXYPASSWORD:
1408 /*
1409 * authentication password to use in the operation
1410 */
1411 result = Curl_setstropt(&data->set.str[STRING_PROXYPASSWORD],
1412 va_arg(param, char *));
1413 break;
1414 case CURLOPT_NOPROXY:
1415 /*
1416 * proxy exception list
1417 */
1418 result = Curl_setstropt(&data->set.str[STRING_NOPROXY],
1419 va_arg(param, char *));
1420 break;
1421#endif
1422
1423 case CURLOPT_RANGE:
1424 /*
1425 * What range of the file you want to transfer
1426 */
1427 result = Curl_setstropt(&data->set.str[STRING_SET_RANGE],
1428 va_arg(param, char *));
1429 break;
1430 case CURLOPT_RESUME_FROM:
1431 /*
1432 * Resume transfer at the given file position
1433 */
1434 arg = va_arg(param, long);
1435 if(arg < -1)
1436 return CURLE_BAD_FUNCTION_ARGUMENT;
1437 data->set.set_resume_from = arg;
1438 break;
1439 case CURLOPT_RESUME_FROM_LARGE:
1440 /*
1441 * Resume transfer at the given file position
1442 */
1443 bigsize = va_arg(param, curl_off_t);
1444 if(bigsize < -1)
1445 return CURLE_BAD_FUNCTION_ARGUMENT;
1446 data->set.set_resume_from = bigsize;
1447 break;
1448 case CURLOPT_DEBUGFUNCTION:
1449 /*
1450 * stderr write callback.
1451 */
1452 data->set.fdebug = va_arg(param, curl_debug_callback);
1453 /*
1454 * if the callback provided is NULL, it'll use the default callback
1455 */
1456 break;
1457 case CURLOPT_DEBUGDATA:
1458 /*
1459 * Set to a void * that should receive all error writes. This
1460 * defaults to CURLOPT_STDERR for normal operations.
1461 */
1462 data->set.debugdata = va_arg(param, void *);
1463 break;
1464 case CURLOPT_STDERR:
1465 /*
1466 * Set to a FILE * that should receive all error writes. This
1467 * defaults to stderr for normal operations.
1468 */
1469 data->set.err = va_arg(param, FILE *);
1470 if(!data->set.err)
1471 data->set.err = stderr;
1472 break;
1473 case CURLOPT_HEADERFUNCTION:
1474 /*
1475 * Set header write callback
1476 */
1477 data->set.fwrite_header = va_arg(param, curl_write_callback);
1478 break;
1479 case CURLOPT_WRITEFUNCTION:
1480 /*
1481 * Set data write callback
1482 */
1483 data->set.fwrite_func = va_arg(param, curl_write_callback);
1484 if(!data->set.fwrite_func) {
1485 data->set.is_fwrite_set = 0;
1486 /* When set to NULL, reset to our internal default function */
1487 data->set.fwrite_func = (curl_write_callback)fwrite;
1488 }
1489 else
1490 data->set.is_fwrite_set = 1;
1491 break;
1492 case CURLOPT_READFUNCTION:
1493 /*
1494 * Read data callback
1495 */
1496 data->set.fread_func_set = va_arg(param, curl_read_callback);
1497 if(!data->set.fread_func_set) {
1498 data->set.is_fread_set = 0;
1499 /* When set to NULL, reset to our internal default function */
1500 data->set.fread_func_set = (curl_read_callback)fread;
1501 }
1502 else
1503 data->set.is_fread_set = 1;
1504 break;
1505 case CURLOPT_SEEKFUNCTION:
1506 /*
1507 * Seek callback. Might be NULL.
1508 */
1509 data->set.seek_func = va_arg(param, curl_seek_callback);
1510 break;
1511 case CURLOPT_SEEKDATA:
1512 /*
1513 * Seek control callback. Might be NULL.
1514 */
1515 data->set.seek_client = va_arg(param, void *);
1516 break;
1517 case CURLOPT_CONV_FROM_NETWORK_FUNCTION:
1518 /*
1519 * "Convert from network encoding" callback
1520 */
1521 data->set.convfromnetwork = va_arg(param, curl_conv_callback);
1522 break;
1523 case CURLOPT_CONV_TO_NETWORK_FUNCTION:
1524 /*
1525 * "Convert to network encoding" callback
1526 */
1527 data->set.convtonetwork = va_arg(param, curl_conv_callback);
1528 break;
1529 case CURLOPT_CONV_FROM_UTF8_FUNCTION:
1530 /*
1531 * "Convert from UTF-8 encoding" callback
1532 */
1533 data->set.convfromutf8 = va_arg(param, curl_conv_callback);
1534 break;
1535 case CURLOPT_IOCTLFUNCTION:
1536 /*
1537 * I/O control callback. Might be NULL.
1538 */
1539 data->set.ioctl_func = va_arg(param, curl_ioctl_callback);
1540 break;
1541 case CURLOPT_IOCTLDATA:
1542 /*
1543 * I/O control data pointer. Might be NULL.
1544 */
1545 data->set.ioctl_client = va_arg(param, void *);
1546 break;
1547 case CURLOPT_SSLCERT:
1548 /*
1549 * String that holds file name of the SSL certificate to use
1550 */
1551 result = Curl_setstropt(&data->set.str[STRING_CERT_ORIG],
1552 va_arg(param, char *));
1553 break;
1554 case CURLOPT_PROXY_SSLCERT:
1555 /*
1556 * String that holds file name of the SSL certificate to use for proxy
1557 */
1558 result = Curl_setstropt(&data->set.str[STRING_CERT_PROXY],
1559 va_arg(param, char *));
1560 break;
1561 case CURLOPT_SSLCERTTYPE:
1562 /*
1563 * String that holds file type of the SSL certificate to use
1564 */
1565 result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_ORIG],
1566 va_arg(param, char *));
1567 break;
1568 case CURLOPT_PROXY_SSLCERTTYPE:
1569 /*
1570 * String that holds file type of the SSL certificate to use for proxy
1571 */
1572 result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_PROXY],
1573 va_arg(param, char *));
1574 break;
1575 case CURLOPT_SSLKEY:
1576 /*
1577 * String that holds file name of the SSL key to use
1578 */
1579 result = Curl_setstropt(&data->set.str[STRING_KEY_ORIG],
1580 va_arg(param, char *));
1581 break;
1582 case CURLOPT_PROXY_SSLKEY:
1583 /*
1584 * String that holds file name of the SSL key to use for proxy
1585 */
1586 result = Curl_setstropt(&data->set.str[STRING_KEY_PROXY],
1587 va_arg(param, char *));
1588 break;
1589 case CURLOPT_SSLKEYTYPE:
1590 /*
1591 * String that holds file type of the SSL key to use
1592 */
1593 result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_ORIG],
1594 va_arg(param, char *));
1595 break;
1596 case CURLOPT_PROXY_SSLKEYTYPE:
1597 /*
1598 * String that holds file type of the SSL key to use for proxy
1599 */
1600 result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_PROXY],
1601 va_arg(param, char *));
1602 break;
1603 case CURLOPT_KEYPASSWD:
1604 /*
1605 * String that holds the SSL or SSH private key password.
1606 */
1607 result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_ORIG],
1608 va_arg(param, char *));
1609 break;
1610 case CURLOPT_PROXY_KEYPASSWD:
1611 /*
1612 * String that holds the SSL private key password for proxy.
1613 */
1614 result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY],
1615 va_arg(param, char *));
1616 break;
1617 case CURLOPT_SSLENGINE:
1618 /*
1619 * String that holds the SSL crypto engine.
1620 */
1621 argptr = va_arg(param, char *);
1622 if(argptr && argptr[0]) {
1623 result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr);
1624 if(!result) {
1625 result = Curl_ssl_set_engine(data, argptr);
1626 }
1627 }
1628 break;
1629
1630 case CURLOPT_SSLENGINE_DEFAULT:
1631 /*
1632 * flag to set engine as default.
1633 */
1634 Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL);
1635 result = Curl_ssl_set_engine_default(data);
1636 break;
1637 case CURLOPT_CRLF:
1638 /*
1639 * Kludgy option to enable CRLF conversions. Subject for removal.
1640 */
1641 data->set.crlf = (0 != va_arg(param, long)) ? TRUE : FALSE;
1642 break;
1643
1644 case CURLOPT_HAPROXYPROTOCOL:
1645 /*
1646 * Set to send the HAProxy Proxy Protocol header
1647 */
1648 data->set.haproxyprotocol = (0 != va_arg(param, long)) ? TRUE : FALSE;
1649 break;
1650
1651 case CURLOPT_INTERFACE:
1652 /*
1653 * Set what interface or address/hostname to bind the socket to when
1654 * performing an operation and thus what from-IP your connection will use.
1655 */
1656 result = Curl_setstropt(&data->set.str[STRING_DEVICE],
1657 va_arg(param, char *));
1658 break;
1659 case CURLOPT_LOCALPORT:
1660 /*
1661 * Set what local port to bind the socket to when performing an operation.
1662 */
1663 arg = va_arg(param, long);
1664 if((arg < 0) || (arg > 65535))
1665 return CURLE_BAD_FUNCTION_ARGUMENT;
1666 data->set.localport = curlx_sltous(arg);
1667 break;
1668 case CURLOPT_LOCALPORTRANGE:
1669 /*
1670 * Set number of local ports to try, starting with CURLOPT_LOCALPORT.
1671 */
1672 arg = va_arg(param, long);
1673 if((arg < 0) || (arg > 65535))
1674 return CURLE_BAD_FUNCTION_ARGUMENT;
1675 data->set.localportrange = curlx_sltosi(arg);
1676 break;
1677 case CURLOPT_KRBLEVEL:
1678 /*
1679 * A string that defines the kerberos security level.
1680 */
1681 result = Curl_setstropt(&data->set.str[STRING_KRB_LEVEL],
1682 va_arg(param, char *));
1683 data->set.krb = (data->set.str[STRING_KRB_LEVEL]) ? TRUE : FALSE;
1684 break;
1685 case CURLOPT_GSSAPI_DELEGATION:
1686 /*
1687 * GSS-API credential delegation bitmask
1688 */
1689 arg = va_arg(param, long);
1690 if(arg < CURLGSSAPI_DELEGATION_NONE)
1691 return CURLE_BAD_FUNCTION_ARGUMENT;
1692 data->set.gssapi_delegation = arg;
1693 break;
1694 case CURLOPT_SSL_VERIFYPEER:
1695 /*
1696 * Enable peer SSL verifying.
1697 */
1698 data->set.ssl.primary.verifypeer = (0 != va_arg(param, long)) ?
1699 TRUE : FALSE;
1700
1701 /* Update the current connection ssl_config. */
1702 if(data->conn) {
1703 data->conn->ssl_config.verifypeer =
1704 data->set.ssl.primary.verifypeer;
1705 }
1706 break;
1707 case CURLOPT_PROXY_SSL_VERIFYPEER:
1708 /*
1709 * Enable peer SSL verifying for proxy.
1710 */
1711 data->set.proxy_ssl.primary.verifypeer =
1712 (0 != va_arg(param, long))?TRUE:FALSE;
1713
1714 /* Update the current connection proxy_ssl_config. */
1715 if(data->conn) {
1716 data->conn->proxy_ssl_config.verifypeer =
1717 data->set.proxy_ssl.primary.verifypeer;
1718 }
1719 break;
1720 case CURLOPT_SSL_VERIFYHOST:
1721 /*
1722 * Enable verification of the host name in the peer certificate
1723 */
1724 arg = va_arg(param, long);
1725
1726 /* Obviously people are not reading documentation and too many thought
1727 this argument took a boolean when it wasn't and misused it. We thus ban
1728 1 as a sensible input and we warn about its use. Then we only have the
1729 2 action internally stored as TRUE. */
1730
1731 if(1 == arg) {
1732 failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
1733 return CURLE_BAD_FUNCTION_ARGUMENT;
1734 }
1735
1736 data->set.ssl.primary.verifyhost = (0 != arg) ? TRUE : FALSE;
1737
1738 /* Update the current connection ssl_config. */
1739 if(data->conn) {
1740 data->conn->ssl_config.verifyhost =
1741 data->set.ssl.primary.verifyhost;
1742 }
1743 break;
1744 case CURLOPT_PROXY_SSL_VERIFYHOST:
1745 /*
1746 * Enable verification of the host name in the peer certificate for proxy
1747 */
1748 arg = va_arg(param, long);
1749
1750 /* Obviously people are not reading documentation and too many thought
1751 this argument took a boolean when it wasn't and misused it. We thus ban
1752 1 as a sensible input and we warn about its use. Then we only have the
1753 2 action internally stored as TRUE. */
1754
1755 if(1 == arg) {
1756 failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
1757 return CURLE_BAD_FUNCTION_ARGUMENT;
1758 }
1759
1760 data->set.proxy_ssl.primary.verifyhost = (0 != arg)?TRUE:FALSE;
1761
1762 /* Update the current connection proxy_ssl_config. */
1763 if(data->conn) {
1764 data->conn->proxy_ssl_config.verifyhost =
1765 data->set.proxy_ssl.primary.verifyhost;
1766 }
1767 break;
1768 case CURLOPT_SSL_VERIFYSTATUS:
1769 /*
1770 * Enable certificate status verifying.
1771 */
1772 if(!Curl_ssl_cert_status_request()) {
1773 result = CURLE_NOT_BUILT_IN;
1774 break;
1775 }
1776
1777 data->set.ssl.primary.verifystatus = (0 != va_arg(param, long)) ?
1778 TRUE : FALSE;
1779
1780 /* Update the current connection ssl_config. */
1781 if(data->conn) {
1782 data->conn->ssl_config.verifystatus =
1783 data->set.ssl.primary.verifystatus;
1784 }
1785 break;
1786 case CURLOPT_SSL_CTX_FUNCTION:
1787 /*
1788 * Set a SSL_CTX callback
1789 */
1790#ifdef USE_SSL
1791 if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
1792 data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
1793 else
1794#endif
1795 result = CURLE_NOT_BUILT_IN;
1796 break;
1797 case CURLOPT_SSL_CTX_DATA:
1798 /*
1799 * Set a SSL_CTX callback parameter pointer
1800 */
1801#ifdef USE_SSL
1802 if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
1803 data->set.ssl.fsslctxp = va_arg(param, void *);
1804 else
1805#endif
1806 result = CURLE_NOT_BUILT_IN;
1807 break;
1808 case CURLOPT_SSL_FALSESTART:
1809 /*
1810 * Enable TLS false start.
1811 */
1812 if(!Curl_ssl_false_start()) {
1813 result = CURLE_NOT_BUILT_IN;
1814 break;
1815 }
1816
1817 data->set.ssl.falsestart = (0 != va_arg(param, long)) ? TRUE : FALSE;
1818 break;
1819 case CURLOPT_CERTINFO:
1820#ifdef USE_SSL
1821 if(Curl_ssl->supports & SSLSUPP_CERTINFO)
1822 data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE;
1823 else
1824#endif
1825 result = CURLE_NOT_BUILT_IN;
1826 break;
1827 case CURLOPT_PINNEDPUBLICKEY:
1828 /*
1829 * Set pinned public key for SSL connection.
1830 * Specify file name of the public key in DER format.
1831 */
1832#ifdef USE_SSL
1833 if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
1834 result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG],
1835 va_arg(param, char *));
1836 else
1837#endif
1838 result = CURLE_NOT_BUILT_IN;
1839 break;
1840 case CURLOPT_PROXY_PINNEDPUBLICKEY:
1841 /*
1842 * Set pinned public key for SSL connection.
1843 * Specify file name of the public key in DER format.
1844 */
1845#ifdef USE_SSL
1846 if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
1847 result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
1848 va_arg(param, char *));
1849 else
1850#endif
1851 result = CURLE_NOT_BUILT_IN;
1852 break;
1853 case CURLOPT_CAINFO:
1854 /*
1855 * Set CA info for SSL connection. Specify file name of the CA certificate
1856 */
1857 result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_ORIG],
1858 va_arg(param, char *));
1859 break;
1860 case CURLOPT_PROXY_CAINFO:
1861 /*
1862 * Set CA info SSL connection for proxy. Specify file name of the
1863 * CA certificate
1864 */
1865 result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY],
1866 va_arg(param, char *));
1867 break;
1868 case CURLOPT_CAPATH:
1869 /*
1870 * Set CA path info for SSL connection. Specify directory name of the CA
1871 * certificates which have been prepared using openssl c_rehash utility.
1872 */
1873#ifdef USE_SSL
1874 if(Curl_ssl->supports & SSLSUPP_CA_PATH)
1875 /* This does not work on windows. */
1876 result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
1877 va_arg(param, char *));
1878 else
1879#endif
1880 result = CURLE_NOT_BUILT_IN;
1881 break;
1882 case CURLOPT_PROXY_CAPATH:
1883 /*
1884 * Set CA path info for SSL connection proxy. Specify directory name of the
1885 * CA certificates which have been prepared using openssl c_rehash utility.
1886 */
1887#ifdef USE_SSL
1888 if(Curl_ssl->supports & SSLSUPP_CA_PATH)
1889 /* This does not work on windows. */
1890 result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY],
1891 va_arg(param, char *));
1892 else
1893#endif
1894 result = CURLE_NOT_BUILT_IN;
1895 break;
1896 case CURLOPT_CRLFILE:
1897 /*
1898 * Set CRL file info for SSL connection. Specify file name of the CRL
1899 * to check certificates revocation
1900 */
1901 result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_ORIG],
1902 va_arg(param, char *));
1903 break;
1904 case CURLOPT_PROXY_CRLFILE:
1905 /*
1906 * Set CRL file info for SSL connection for proxy. Specify file name of the
1907 * CRL to check certificates revocation
1908 */
1909 result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY],
1910 va_arg(param, char *));
1911 break;
1912 case CURLOPT_ISSUERCERT:
1913 /*
1914 * Set Issuer certificate file
1915 * to check certificates issuer
1916 */
1917 result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_ORIG],
1918 va_arg(param, char *));
1919 break;
1920 case CURLOPT_TELNETOPTIONS:
1921 /*
1922 * Set a linked list of telnet options
1923 */
1924 data->set.telnet_options = va_arg(param, struct curl_slist *);
1925 break;
1926
1927 case CURLOPT_BUFFERSIZE:
1928 /*
1929 * The application kindly asks for a differently sized receive buffer.
1930 * If it seems reasonable, we'll use it.
1931 */
1932 arg = va_arg(param, long);
1933
1934 if(arg > READBUFFER_MAX)
1935 arg = READBUFFER_MAX;
1936 else if(arg < 1)
1937 arg = READBUFFER_SIZE;
1938 else if(arg < READBUFFER_MIN)
1939 arg = READBUFFER_MIN;
1940
1941 /* Resize if new size */
1942 if(arg != data->set.buffer_size) {
1943 char *newbuff = realloc(data->state.buffer, arg + 1);
1944 if(!newbuff) {
1945 DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
1946 result = CURLE_OUT_OF_MEMORY;
1947 }
1948 else
1949 data->state.buffer = newbuff;
1950 }
1951 data->set.buffer_size = arg;
1952
1953 break;
1954
1955 case CURLOPT_UPLOAD_BUFFERSIZE:
1956 /*
1957 * The application kindly asks for a differently sized upload buffer.
1958 * Cap it to sensible.
1959 */
1960 arg = va_arg(param, long);
1961
1962 if(arg > UPLOADBUFFER_MAX)
1963 arg = UPLOADBUFFER_MAX;
1964 else if(arg < UPLOADBUFFER_MIN)
1965 arg = UPLOADBUFFER_MIN;
1966
1967 data->set.upload_buffer_size = arg;
1968 Curl_safefree(data->state.ulbuf); /* force a realloc next opportunity */
1969 break;
1970
1971 case CURLOPT_NOSIGNAL:
1972 /*
1973 * The application asks not to set any signal() or alarm() handlers,
1974 * even when using a timeout.
1975 */
1976 data->set.no_signal = (0 != va_arg(param, long)) ? TRUE : FALSE;
1977 break;
1978
1979 case CURLOPT_SHARE:
1980 {
1981 struct Curl_share *set;
1982 set = va_arg(param, struct Curl_share *);
1983
1984 /* disconnect from old share, if any */
1985 if(data->share) {
1986 Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
1987
1988 if(data->dns.hostcachetype == HCACHE_SHARED) {
1989 data->dns.hostcache = NULL;
1990 data->dns.hostcachetype = HCACHE_NONE;
1991 }
1992
1993#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
1994 if(data->share->cookies == data->cookies)
1995 data->cookies = NULL;
1996#endif
1997
1998 if(data->share->sslsession == data->state.session)
1999 data->state.session = NULL;
2000
2001#ifdef USE_LIBPSL
2002 if(data->psl == &data->share->psl)
2003 data->psl = data->multi? &data->multi->psl: NULL;
2004#endif
2005
2006 data->share->dirty--;
2007
2008 Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
2009 data->share = NULL;
2010 }
2011
2012 /* use new share if it set */
2013 data->share = set;
2014 if(data->share) {
2015
2016 Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
2017
2018 data->share->dirty++;
2019
2020 if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) {
2021 /* use shared host cache */
2022 data->dns.hostcache = &data->share->hostcache;
2023 data->dns.hostcachetype = HCACHE_SHARED;
2024 }
2025#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
2026 if(data->share->cookies) {
2027 /* use shared cookie list, first free own one if any */
2028 Curl_cookie_cleanup(data->cookies);
2029 /* enable cookies since we now use a share that uses cookies! */
2030 data->cookies = data->share->cookies;
2031 }
2032#endif /* CURL_DISABLE_HTTP */
2033 if(data->share->sslsession) {
2034 data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
2035 data->state.session = data->share->sslsession;
2036 }
2037#ifdef USE_LIBPSL
2038 if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
2039 data->psl = &data->share->psl;
2040#endif
2041
2042 Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
2043 }
2044 /* check for host cache not needed,
2045 * it will be done by curl_easy_perform */
2046 }
2047 break;
2048
2049 case CURLOPT_PRIVATE:
2050 /*
2051 * Set private data pointer.
2052 */
2053 data->set.private_data = va_arg(param, void *);
2054 break;
2055
2056 case CURLOPT_MAXFILESIZE:
2057 /*
2058 * Set the maximum size of a file to download.
2059 */
2060 arg = va_arg(param, long);
2061 if(arg < 0)
2062 return CURLE_BAD_FUNCTION_ARGUMENT;
2063 data->set.max_filesize = arg;
2064 break;
2065
2066#ifdef USE_SSL
2067 case CURLOPT_USE_SSL:
2068 /*
2069 * Make transfers attempt to use SSL/TLS.
2070 */
2071 arg = va_arg(param, long);
2072 if((arg < CURLUSESSL_NONE) || (arg > CURLUSESSL_ALL))
2073 return CURLE_BAD_FUNCTION_ARGUMENT;
2074 data->set.use_ssl = (curl_usessl)arg;
2075 break;
2076
2077 case CURLOPT_SSL_OPTIONS:
2078 arg = va_arg(param, long);
2079 data->set.ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
2080 data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
2081 break;
2082
2083 case CURLOPT_PROXY_SSL_OPTIONS:
2084 arg = va_arg(param, long);
2085 data->set.proxy_ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
2086 data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
2087 break;
2088
2089#endif
2090 case CURLOPT_FTPSSLAUTH:
2091 /*
2092 * Set a specific auth for FTP-SSL transfers.
2093 */
2094 arg = va_arg(param, long);
2095 if((arg < CURLFTPAUTH_DEFAULT) || (arg > CURLFTPAUTH_TLS))
2096 return CURLE_BAD_FUNCTION_ARGUMENT;
2097 data->set.ftpsslauth = (curl_ftpauth)arg;
2098 break;
2099
2100 case CURLOPT_IPRESOLVE:
2101 arg = va_arg(param, long);
2102 if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6))
2103 return CURLE_BAD_FUNCTION_ARGUMENT;
2104 data->set.ipver = arg;
2105 break;
2106
2107 case CURLOPT_MAXFILESIZE_LARGE:
2108 /*
2109 * Set the maximum size of a file to download.
2110 */
2111 bigsize = va_arg(param, curl_off_t);
2112 if(bigsize < 0)
2113 return CURLE_BAD_FUNCTION_ARGUMENT;
2114 data->set.max_filesize = bigsize;
2115 break;
2116
2117 case CURLOPT_TCP_NODELAY:
2118 /*
2119 * Enable or disable TCP_NODELAY, which will disable/enable the Nagle
2120 * algorithm
2121 */
2122 data->set.tcp_nodelay = (0 != va_arg(param, long)) ? TRUE : FALSE;
2123 break;
2124
2125 case CURLOPT_FTP_ACCOUNT:
2126 result = Curl_setstropt(&data->set.str[STRING_FTP_ACCOUNT],
2127 va_arg(param, char *));
2128 break;
2129
2130 case CURLOPT_IGNORE_CONTENT_LENGTH:
2131 data->set.ignorecl = (0 != va_arg(param, long)) ? TRUE : FALSE;
2132 break;
2133
2134 case CURLOPT_CONNECT_ONLY:
2135 /*
2136 * No data transfer, set up connection and let application use the socket
2137 */
2138 data->set.connect_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
2139 break;
2140
2141 case CURLOPT_FTP_ALTERNATIVE_TO_USER:
2142 result = Curl_setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],
2143 va_arg(param, char *));
2144 break;
2145
2146 case CURLOPT_SOCKOPTFUNCTION:
2147 /*
2148 * socket callback function: called after socket() but before connect()
2149 */
2150 data->set.fsockopt = va_arg(param, curl_sockopt_callback);
2151 break;
2152
2153 case CURLOPT_SOCKOPTDATA:
2154 /*
2155 * socket callback data pointer. Might be NULL.
2156 */
2157 data->set.sockopt_client = va_arg(param, void *);
2158 break;
2159
2160 case CURLOPT_OPENSOCKETFUNCTION:
2161 /*
2162 * open/create socket callback function: called instead of socket(),
2163 * before connect()
2164 */
2165 data->set.fopensocket = va_arg(param, curl_opensocket_callback);
2166 break;
2167
2168 case CURLOPT_OPENSOCKETDATA:
2169 /*
2170 * socket callback data pointer. Might be NULL.
2171 */
2172 data->set.opensocket_client = va_arg(param, void *);
2173 break;
2174
2175 case CURLOPT_CLOSESOCKETFUNCTION:
2176 /*
2177 * close socket callback function: called instead of close()
2178 * when shutting down a connection
2179 */
2180 data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
2181 break;
2182
2183 case CURLOPT_RESOLVER_START_FUNCTION:
2184 /*
2185 * resolver start callback function: called before a new resolver request
2186 * is started
2187 */
2188 data->set.resolver_start = va_arg(param, curl_resolver_start_callback);
2189 break;
2190
2191 case CURLOPT_RESOLVER_START_DATA:
2192 /*
2193 * resolver start callback data pointer. Might be NULL.
2194 */
2195 data->set.resolver_start_client = va_arg(param, void *);
2196 break;
2197
2198 case CURLOPT_CLOSESOCKETDATA:
2199 /*
2200 * socket callback data pointer. Might be NULL.
2201 */
2202 data->set.closesocket_client = va_arg(param, void *);
2203 break;
2204
2205 case CURLOPT_SSL_SESSIONID_CACHE:
2206 data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ?
2207 TRUE : FALSE;
2208 data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
2209 break;
2210
2211#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
2212 /* we only include SSH options if explicitly built to support SSH */
2213 case CURLOPT_SSH_AUTH_TYPES:
2214 data->set.ssh_auth_types = va_arg(param, long);
2215 break;
2216
2217 case CURLOPT_SSH_PUBLIC_KEYFILE:
2218 /*
2219 * Use this file instead of the $HOME/.ssh/id_dsa.pub file
2220 */
2221 result = Curl_setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],
2222 va_arg(param, char *));
2223 break;
2224
2225 case CURLOPT_SSH_PRIVATE_KEYFILE:
2226 /*
2227 * Use this file instead of the $HOME/.ssh/id_dsa file
2228 */
2229 result = Curl_setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],
2230 va_arg(param, char *));
2231 break;
2232 case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
2233 /*
2234 * Option to allow for the MD5 of the host public key to be checked
2235 * for validation purposes.
2236 */
2237 result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],
2238 va_arg(param, char *));
2239 break;
2240
2241 case CURLOPT_SSH_KNOWNHOSTS:
2242 /*
2243 * Store the file name to read known hosts from.
2244 */
2245 result = Curl_setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],
2246 va_arg(param, char *));
2247 break;
2248
2249 case CURLOPT_SSH_KEYFUNCTION:
2250 /* setting to NULL is fine since the ssh.c functions themselves will
2251 then rever to use the internal default */
2252 data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
2253 break;
2254
2255 case CURLOPT_SSH_KEYDATA:
2256 /*
2257 * Custom client data to pass to the SSH keyfunc callback
2258 */
2259 data->set.ssh_keyfunc_userp = va_arg(param, void *);
2260 break;
2261#endif /* USE_LIBSSH2 */
2262
2263 case CURLOPT_HTTP_TRANSFER_DECODING:
2264 /*
2265 * disable libcurl transfer encoding is used
2266 */
2267 data->set.http_te_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
2268 break;
2269
2270 case CURLOPT_HTTP_CONTENT_DECODING:
2271 /*
2272 * raw data passed to the application when content encoding is used
2273 */
2274 data->set.http_ce_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
2275 break;
2276
2277 case CURLOPT_NEW_FILE_PERMS:
2278 /*
2279 * Uses these permissions instead of 0644
2280 */
2281 arg = va_arg(param, long);
2282 if((arg < 0) || (arg > 0777))
2283 return CURLE_BAD_FUNCTION_ARGUMENT;
2284 data->set.new_file_perms = arg;
2285 break;
2286
2287 case CURLOPT_NEW_DIRECTORY_PERMS:
2288 /*
2289 * Uses these permissions instead of 0755
2290 */
2291 arg = va_arg(param, long);
2292 if((arg < 0) || (arg > 0777))
2293 return CURLE_BAD_FUNCTION_ARGUMENT;
2294 data->set.new_directory_perms = arg;
2295 break;
2296
2297 case CURLOPT_ADDRESS_SCOPE:
2298 /*
2299 * We always get longs when passed plain numericals, but for this value we
2300 * know that an unsigned int will always hold the value so we blindly
2301 * typecast to this type
2302 */
2303 arg = va_arg(param, long);
2304 if((arg < 0) || (arg > 0xf))
2305 return CURLE_BAD_FUNCTION_ARGUMENT;
2306 data->set.scope_id = curlx_sltoui(arg);
2307 break;
2308
2309 case CURLOPT_PROTOCOLS:
2310 /* set the bitmask for the protocols that are allowed to be used for the
2311 transfer, which thus helps the app which takes URLs from users or other
2312 external inputs and want to restrict what protocol(s) to deal
2313 with. Defaults to CURLPROTO_ALL. */
2314 data->set.allowed_protocols = va_arg(param, long);
2315 break;
2316
2317 case CURLOPT_REDIR_PROTOCOLS:
2318 /* set the bitmask for the protocols that libcurl is allowed to follow to,
2319 as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
2320 to be set in both bitmasks to be allowed to get redirected to. Defaults
2321 to all protocols except FILE and SCP. */
2322 data->set.redir_protocols = va_arg(param, long);
2323 break;
2324
2325 case CURLOPT_DEFAULT_PROTOCOL:
2326 /* Set the protocol to use when the URL doesn't include any protocol */
2327 result = Curl_setstropt(&data->set.str[STRING_DEFAULT_PROTOCOL],
2328 va_arg(param, char *));
2329 break;
2330
2331 case CURLOPT_MAIL_FROM:
2332 /* Set the SMTP mail originator */
2333 result = Curl_setstropt(&data->set.str[STRING_MAIL_FROM],
2334 va_arg(param, char *));
2335 break;
2336
2337 case CURLOPT_MAIL_AUTH:
2338 /* Set the SMTP auth originator */
2339 result = Curl_setstropt(&data->set.str[STRING_MAIL_AUTH],
2340 va_arg(param, char *));
2341 break;
2342
2343 case CURLOPT_MAIL_RCPT:
2344 /* Set the list of mail recipients */
2345 data->set.mail_rcpt = va_arg(param, struct curl_slist *);
2346 break;
2347
2348 case CURLOPT_SASL_IR:
2349 /* Enable/disable SASL initial response */
2350 data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;
2351 break;
2352
2353 case CURLOPT_RTSP_REQUEST:
2354 {
2355 /*
2356 * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
2357 * Would this be better if the RTSPREQ_* were just moved into here?
2358 */
2359 long curl_rtspreq = va_arg(param, long);
2360 Curl_RtspReq rtspreq = RTSPREQ_NONE;
2361 switch(curl_rtspreq) {
2362 case CURL_RTSPREQ_OPTIONS:
2363 rtspreq = RTSPREQ_OPTIONS;
2364 break;
2365
2366 case CURL_RTSPREQ_DESCRIBE:
2367 rtspreq = RTSPREQ_DESCRIBE;
2368 break;
2369
2370 case CURL_RTSPREQ_ANNOUNCE:
2371 rtspreq = RTSPREQ_ANNOUNCE;
2372 break;
2373
2374 case CURL_RTSPREQ_SETUP:
2375 rtspreq = RTSPREQ_SETUP;
2376 break;
2377
2378 case CURL_RTSPREQ_PLAY:
2379 rtspreq = RTSPREQ_PLAY;
2380 break;
2381
2382 case CURL_RTSPREQ_PAUSE:
2383 rtspreq = RTSPREQ_PAUSE;
2384 break;
2385
2386 case CURL_RTSPREQ_TEARDOWN:
2387 rtspreq = RTSPREQ_TEARDOWN;
2388 break;
2389
2390 case CURL_RTSPREQ_GET_PARAMETER:
2391 rtspreq = RTSPREQ_GET_PARAMETER;
2392 break;
2393
2394 case CURL_RTSPREQ_SET_PARAMETER:
2395 rtspreq = RTSPREQ_SET_PARAMETER;
2396 break;
2397
2398 case CURL_RTSPREQ_RECORD:
2399 rtspreq = RTSPREQ_RECORD;
2400 break;
2401
2402 case CURL_RTSPREQ_RECEIVE:
2403 rtspreq = RTSPREQ_RECEIVE;
2404 break;
2405 default:
2406 rtspreq = RTSPREQ_NONE;
2407 }
2408
2409 data->set.rtspreq = rtspreq;
2410 break;
2411 }
2412
2413
2414 case CURLOPT_RTSP_SESSION_ID:
2415 /*
2416 * Set the RTSP Session ID manually. Useful if the application is
2417 * resuming a previously established RTSP session
2418 */
2419 result = Curl_setstropt(&data->set.str[STRING_RTSP_SESSION_ID],
2420 va_arg(param, char *));
2421 break;
2422
2423 case CURLOPT_RTSP_STREAM_URI:
2424 /*
2425 * Set the Stream URI for the RTSP request. Unless the request is
2426 * for generic server options, the application will need to set this.
2427 */
2428 result = Curl_setstropt(&data->set.str[STRING_RTSP_STREAM_URI],
2429 va_arg(param, char *));
2430 break;
2431
2432 case CURLOPT_RTSP_TRANSPORT:
2433 /*
2434 * The content of the Transport: header for the RTSP request
2435 */
2436 result = Curl_setstropt(&data->set.str[STRING_RTSP_TRANSPORT],
2437 va_arg(param, char *));
2438 break;
2439
2440 case CURLOPT_RTSP_CLIENT_CSEQ:
2441 /*
2442 * Set the CSEQ number to issue for the next RTSP request. Useful if the
2443 * application is resuming a previously broken connection. The CSEQ
2444 * will increment from this new number henceforth.
2445 */
2446 data->state.rtsp_next_client_CSeq = va_arg(param, long);
2447 break;
2448
2449 case CURLOPT_RTSP_SERVER_CSEQ:
2450 /* Same as the above, but for server-initiated requests */
2451 data->state.rtsp_next_client_CSeq = va_arg(param, long);
2452 break;
2453
2454 case CURLOPT_INTERLEAVEDATA:
2455 data->set.rtp_out = va_arg(param, void *);
2456 break;
2457 case CURLOPT_INTERLEAVEFUNCTION:
2458 /* Set the user defined RTP write function */
2459 data->set.fwrite_rtp = va_arg(param, curl_write_callback);
2460 break;
2461
2462 case CURLOPT_WILDCARDMATCH:
2463 data->set.wildcard_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE;
2464 break;
2465 case CURLOPT_CHUNK_BGN_FUNCTION:
2466 data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
2467 break;
2468 case CURLOPT_CHUNK_END_FUNCTION:
2469 data->set.chunk_end = va_arg(param, curl_chunk_end_callback);
2470 break;
2471 case CURLOPT_FNMATCH_FUNCTION:
2472 data->set.fnmatch = va_arg(param, curl_fnmatch_callback);
2473 break;
2474 case CURLOPT_CHUNK_DATA:
2475 data->wildcard.customptr = va_arg(param, void *);
2476 break;
2477 case CURLOPT_FNMATCH_DATA:
2478 data->set.fnmatch_data = va_arg(param, void *);
2479 break;
2480#ifdef USE_TLS_SRP
2481 case CURLOPT_TLSAUTH_USERNAME:
2482 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_ORIG],
2483 va_arg(param, char *));
2484 if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
2485 data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
2486 break;
2487 case CURLOPT_PROXY_TLSAUTH_USERNAME:
2488 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
2489 va_arg(param, char *));
2490 if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2491 !data->set.proxy_ssl.authtype)
2492 data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
2493 break;
2494 case CURLOPT_TLSAUTH_PASSWORD:
2495 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_ORIG],
2496 va_arg(param, char *));
2497 if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
2498 data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
2499 break;
2500 case CURLOPT_PROXY_TLSAUTH_PASSWORD:
2501 result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
2502 va_arg(param, char *));
2503 if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2504 !data->set.proxy_ssl.authtype)
2505 data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
2506 break;
2507 case CURLOPT_TLSAUTH_TYPE:
2508 argptr = va_arg(param, char *);
2509 if(!argptr ||
2510 strncasecompare(argptr, "SRP", strlen("SRP")))
2511 data->set.ssl.authtype = CURL_TLSAUTH_SRP;
2512 else
2513 data->set.ssl.authtype = CURL_TLSAUTH_NONE;
2514 break;
2515 case CURLOPT_PROXY_TLSAUTH_TYPE:
2516 argptr = va_arg(param, char *);
2517 if(!argptr ||
2518 strncasecompare(argptr, "SRP", strlen("SRP")))
2519 data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP;
2520 else
2521 data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
2522 break;
2523#endif
2524 case CURLOPT_DNS_SERVERS:
2525 result = Curl_set_dns_servers(data, va_arg(param, char *));
2526 break;
2527 case CURLOPT_DNS_INTERFACE:
2528 result = Curl_set_dns_interface(data, va_arg(param, char *));
2529 break;
2530 case CURLOPT_DNS_LOCAL_IP4:
2531 result = Curl_set_dns_local_ip4(data, va_arg(param, char *));
2532 break;
2533 case CURLOPT_DNS_LOCAL_IP6:
2534 result = Curl_set_dns_local_ip6(data, va_arg(param, char *));
2535 break;
2536
2537 case CURLOPT_TCP_KEEPALIVE:
2538 data->set.tcp_keepalive = (0 != va_arg(param, long)) ? TRUE : FALSE;
2539 break;
2540 case CURLOPT_TCP_KEEPIDLE:
2541 arg = va_arg(param, long);
2542 if(arg < 0)
2543 return CURLE_BAD_FUNCTION_ARGUMENT;
2544 data->set.tcp_keepidle = arg;
2545 break;
2546 case CURLOPT_TCP_KEEPINTVL:
2547 arg = va_arg(param, long);
2548 if(arg < 0)
2549 return CURLE_BAD_FUNCTION_ARGUMENT;
2550 data->set.tcp_keepintvl = arg;
2551 break;
2552 case CURLOPT_TCP_FASTOPEN:
2553#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
2554 defined(TCP_FASTOPEN_CONNECT)
2555 data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE;
2556#else
2557 result = CURLE_NOT_BUILT_IN;
2558#endif
2559 break;
2560 case CURLOPT_SSL_ENABLE_NPN:
2561 data->set.ssl_enable_npn = (0 != va_arg(param, long)) ? TRUE : FALSE;
2562 break;
2563 case CURLOPT_SSL_ENABLE_ALPN:
2564 data->set.ssl_enable_alpn = (0 != va_arg(param, long)) ? TRUE : FALSE;
2565 break;
2566
2567#ifdef USE_UNIX_SOCKETS
2568 case CURLOPT_UNIX_SOCKET_PATH:
2569 data->set.abstract_unix_socket = FALSE;
2570 result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
2571 va_arg(param, char *));
2572 break;
2573 case CURLOPT_ABSTRACT_UNIX_SOCKET:
2574 data->set.abstract_unix_socket = TRUE;
2575 result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
2576 va_arg(param, char *));
2577 break;
2578#endif
2579
2580 case CURLOPT_PATH_AS_IS:
2581 data->set.path_as_is = (0 != va_arg(param, long)) ? TRUE : FALSE;
2582 break;
2583 case CURLOPT_PIPEWAIT:
2584 data->set.pipewait = (0 != va_arg(param, long)) ? TRUE : FALSE;
2585 break;
2586 case CURLOPT_STREAM_WEIGHT:
2587#ifndef USE_NGHTTP2
2588 return CURLE_NOT_BUILT_IN;
2589#else
2590 arg = va_arg(param, long);
2591 if((arg >= 1) && (arg <= 256))
2592 data->set.stream_weight = (int)arg;
2593 break;
2594#endif
2595 case CURLOPT_STREAM_DEPENDS:
2596 case CURLOPT_STREAM_DEPENDS_E:
2597 {
2598#ifndef USE_NGHTTP2
2599 return CURLE_NOT_BUILT_IN;
2600#else
2601 struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
2602 if(!dep || GOOD_EASY_HANDLE(dep)) {
2603 if(data->set.stream_depends_on) {
2604 Curl_http2_remove_child(data->set.stream_depends_on, data);
2605 }
2606 Curl_http2_add_child(dep, data, (option == CURLOPT_STREAM_DEPENDS_E));
2607 }
2608 break;
2609#endif
2610 }
2611 case CURLOPT_CONNECT_TO:
2612 data->set.connect_to = va_arg(param, struct curl_slist *);
2613 break;
2614 case CURLOPT_SUPPRESS_CONNECT_HEADERS:
2615 data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE;
2616 break;
2617 case CURLOPT_SSH_COMPRESSION:
2618 data->set.ssh_compression = (0 != va_arg(param, long))?TRUE:FALSE;
2619 break;
2620 case CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS:
2621 arg = va_arg(param, long);
2622 if(arg < 0)
2623 return CURLE_BAD_FUNCTION_ARGUMENT;
2624 data->set.happy_eyeballs_timeout = arg;
2625 break;
2626 case CURLOPT_DNS_SHUFFLE_ADDRESSES:
2627 data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE;
2628 break;
2629 case CURLOPT_DISALLOW_USERNAME_IN_URL:
2630 data->set.disallow_username_in_url =
2631 (0 != va_arg(param, long)) ? TRUE : FALSE;
2632 break;
2633 case CURLOPT_DOH_URL:
2634 result = Curl_setstropt(&data->set.str[STRING_DOH],
2635 va_arg(param, char *));
2636 data->set.doh = data->set.str[STRING_DOH]?TRUE:FALSE;
2637 break;
2638 case CURLOPT_UPKEEP_INTERVAL_MS:
2639 arg = va_arg(param, long);
2640 if(arg < 0)
2641 return CURLE_BAD_FUNCTION_ARGUMENT;
2642 data->set.upkeep_interval_ms = arg;
2643 break;
2644 case CURLOPT_TRAILERFUNCTION:
2645#ifndef CURL_DISABLE_HTTP
2646 data->set.trailer_callback = va_arg(param, curl_trailer_callback);
2647#endif
2648 break;
2649 case CURLOPT_TRAILERDATA:
2650#ifndef CURL_DISABLE_HTTP
2651 data->set.trailer_data = va_arg(param, void *);
2652#endif
2653 break;
2654 default:
2655 /* unknown tag and its companion, just ignore: */
2656 result = CURLE_UNKNOWN_OPTION;
2657 break;
2658 }
2659
2660 return result;
2661}
2662
2663/*
2664 * curl_easy_setopt() is the external interface for setting options on an
2665 * easy handle.
2666 *
2667 * NOTE: This is one of few API functions that are allowed to be called from
2668 * within a callback.
2669 */
2670
2671#undef curl_easy_setopt
2672CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
2673{
2674 va_list arg;
2675 CURLcode result;
2676
2677 if(!data)
2678 return CURLE_BAD_FUNCTION_ARGUMENT;
2679
2680 va_start(arg, tag);
2681
2682 result = Curl_vsetopt(data, tag, arg);
2683
2684 va_end(arg);
2685 return result;
2686}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette