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