* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
#endif
#define CURL_CA_CERT_ERRORMSG1 \
- "More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
+ "More details here: https://curl.haxx.se/docs/sslcerts.html\n\n" \
"curl performs SSL certificate verification by default, " \
"using a \"bundle\"\n" \
" of Certificate Authority (CA) public keys (CA certs). If the default\n" \
int ret_stat;
FILE * file;
- file = fopen(name, "r");
+ file = fopen(name, "r"); /* VMS */
if(file == NULL) {
return 0;
}
if(!curlx_strequal(config->headerfile, "-")) {
FILE *newfile = fopen(config->headerfile, "wb");
if(!newfile) {
- warnf(config, "Failed to open %s\n", config->headerfile);
+ warnf(config->global, "Failed to open %s\n", config->headerfile);
result = CURLE_WRITE_ERROR;
goto quit_curl;
}
result = CURLE_WRITE_ERROR;
goto quit_urls;
}
-#if defined(MSDOS) || defined(WIN32)
- /* For DOS and WIN32, we do some major replacing of
- bad characters in the file name before using it */
- outfile = sanitize_dos_name(outfile);
- if(!outfile) {
- result = CURLE_OUT_OF_MEMORY;
- goto show_error;
- }
-#endif /* MSDOS || WIN32 */
}
else if(urls) {
/* fill '#1' ... '#9' terms from URL pattern */
Curl_safefree(storefile);
if(result) {
/* bad globbing */
- warnf(config, "bad output glob!\n");
+ warnf(config->global, "bad output glob!\n");
goto quit_urls;
}
}
* we should warn him/her.
*/
if(config->proxyanyauth || (authbits>1)) {
- warnf(config,
+ warnf(config->global,
"Using --anyauth or --proxy-anyauth with upload from stdin"
" involves a big risk of it not working. Use a temporary"
" file or a fixed auth type instead!\n");
set_binmode(stdin);
if(curlx_strequal(uploadfile, ".")) {
if(curlx_nonblock((curl_socket_t)infd, TRUE) < 0)
- warnf(config,
+ warnf(config->global,
"fcntl failed on fd=%d: %s\n", infd, strerror(errno));
}
}
else if(!config->use_metalink)
my_setopt(curl, CURLOPT_HEADER, config->include_headers?1L:0L);
- if(config->xoauth2_bearer)
- my_setopt_str(curl, CURLOPT_XOAUTH2_BEARER, config->xoauth2_bearer);
+ if(config->oauth_bearer)
+ my_setopt_str(curl, CURLOPT_XOAUTH2_BEARER, config->oauth_bearer);
#if !defined(CURL_DISABLE_PROXY)
{
(long)CURLAUTH_BASIC);
/* new in libcurl 7.19.4 */
- my_setopt(curl, CURLOPT_NOPROXY, config->noproxy);
+ my_setopt_str(curl, CURLOPT_NOPROXY, config->noproxy);
}
#endif
my_setopt_enum(curl, CURLOPT_NETRC, (long)CURL_NETRC_IGNORED);
if(config->netrc_file)
- my_setopt(curl, CURLOPT_NETRC_FILE, config->netrc_file);
+ my_setopt_str(curl, CURLOPT_NETRC_FILE, config->netrc_file);
my_setopt(curl, CURLOPT_TRANSFERTEXT, config->use_ascii?1L:0L);
if(config->login_options)
my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
config->postfieldsize);
break;
- case HTTPREQ_POST:
+ case HTTPREQ_FORMPOST:
my_setopt_httppost(curl, CURLOPT_HTTPPOST, config->httppost);
break;
default:
/* new in libcurl 7.5 */
my_setopt(curl, CURLOPT_MAXREDIRS, config->maxredirs);
- /* new in libcurl 7.9.1 */
if(config->httpversion)
my_setopt_enum(curl, CURLOPT_HTTP_VERSION, config->httpversion);
+ else if(curlinfo->features & CURL_VERSION_HTTP2) {
+ my_setopt_enum(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
+ }
/* new in libcurl 7.10.6 (default is Basic) */
if(config->authtype)
else
my_setopt(curl, CURLOPT_RESUME_FROM_LARGE, CURL_OFF_T_C(0));
- my_setopt_str(curl, CURLOPT_SSLCERT, config->cert);
- my_setopt_str(curl, CURLOPT_SSLCERTTYPE, config->cert_type);
- my_setopt_str(curl, CURLOPT_SSLKEY, config->key);
- my_setopt_str(curl, CURLOPT_SSLKEYTYPE, config->key_type);
my_setopt_str(curl, CURLOPT_KEYPASSWD, config->key_passwd);
if(built_in_protos & (CURLPROTO_SCP|CURLPROTO_SFTP)) {
my_setopt_str(curl, CURLOPT_PINNEDPUBLICKEY, config->pinnedpubkey);
if(curlinfo->features & CURL_VERSION_SSL) {
+ my_setopt_str(curl, CURLOPT_SSLCERT, config->cert);
+ my_setopt_str(curl, CURLOPT_SSLCERTTYPE, config->cert_type);
+ my_setopt_str(curl, CURLOPT_SSLKEY, config->key);
+ my_setopt_str(curl, CURLOPT_SSLKEYTYPE, config->key_type);
+
if(config->insecure_ok) {
my_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
/* libcurl default is strict verifyhost -> 2L */
/* my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); */
}
+
+ if(config->verifystatus)
+ my_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L);
+
+ if(config->falsestart)
+ my_setopt(curl, CURLOPT_SSL_FALSESTART, 1L);
+
+ my_setopt_enum(curl, CURLOPT_SSLVERSION, config->ssl_version);
}
+ if(config->path_as_is)
+ my_setopt(curl, CURLOPT_PATH_AS_IS, 1L);
if(built_in_protos & (CURLPROTO_SCP|CURLPROTO_SFTP)) {
if(!config->insecure_ok) {
my_setopt(curl, CURLOPT_COOKIESESSION, config->cookiesession?1L:0L);
#else
if(config->cookie || config->cookiefile || config->cookiejar) {
- warnf(config, "cookie option(s) used even though cookie support "
- "is disabled!\n");
+ warnf(config->global, "cookie option(s) used even though cookie "
+ "support is disabled!\n");
return CURLE_NOT_BUILT_IN;
}
#endif
- my_setopt_enum(curl, CURLOPT_SSLVERSION, config->ssl_version);
my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond);
my_setopt(curl, CURLOPT_TIMEVALUE, (long)config->condtime);
my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
+ customrequest_helper(config, config->httpreq, config->customrequest);
my_setopt(curl, CURLOPT_STDERR, global->errors);
/* three new ones in libcurl 7.3: */
my_setopt_enum(curl, CURLOPT_FTP_SSL_CCC,
(long)config->ftp_ssl_ccc_mode);
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- {
- /* TODO: Make this a run-time check instead of compile-time one. */
+ /* new in curl 7.19.4 */
+ if(config->socks5_gssapi_service)
+ my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE,
+ config->socks5_gssapi_service);
- /* new in curl 7.19.4 */
- if(config->socks5_gssapi_service)
- my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE,
- config->socks5_gssapi_service);
+ /* new in curl 7.19.4 */
+ if(config->socks5_gssapi_nec)
+ my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_NEC,
+ config->socks5_gssapi_nec);
+
+ /* new in curl 7.43.0 */
+ if(config->proxy_service_name)
+ my_setopt_str(curl, CURLOPT_PROXY_SERVICE_NAME,
+ config->proxy_service_name);
+
+ /* new in curl 7.43.0 */
+ if(config->service_name)
+ my_setopt_str(curl, CURLOPT_SERVICE_NAME,
+ config->service_name);
- /* new in curl 7.19.4 */
- if(config->socks5_gssapi_nec)
- my_setopt_str(curl, CURLOPT_SOCKS5_GSSAPI_NEC,
- config->socks5_gssapi_nec);
- }
-#endif
/* curl 7.13.0 */
my_setopt_str(curl, CURLOPT_FTP_ACCOUNT, config->ftp_account);
if(!config->nokeepalive) {
my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
if(config->alivetime != 0) {
-#if !defined(TCP_KEEPIDLE) || !defined(TCP_KEEPINTVL)
- warnf(config, "Keep-alive functionality somewhat crippled due to "
- "missing support in your operating system!\n");
-#endif
my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->alivetime);
my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->alivetime);
}
my_setopt_str(curl, CURLOPT_GSSAPI_DELEGATION,
config->gssapi_delegation);
- /* new in 7.25.0 */
- if(config->ssl_allow_beast)
- my_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_ALLOW_BEAST);
+ /* new in 7.25.0 and 7.44.0 */
+ {
+ long mask = (config->ssl_allow_beast ? CURLSSLOPT_ALLOW_BEAST : 0) |
+ (config->ssl_no_revoke ? CURLSSLOPT_NO_REVOKE : 0);
+ if(mask)
+ my_setopt_bitmask(curl, CURLOPT_SSL_OPTIONS, mask);
+ }
if(config->mail_auth)
my_setopt_str(curl, CURLOPT_MAIL_AUTH, config->mail_auth);
my_setopt_str(curl, CURLOPT_UNIX_SOCKET_PATH,
config->unix_socket_path);
+ /* new in 7.45.0 */
+ if(config->proto_default)
+ my_setopt_str(curl, CURLOPT_DEFAULT_PROTOCOL, config->proto_default);
+
+ /* new in 7.47.0 */
+ if(config->expect100timeout > 0)
+ my_setopt_str(curl, CURLOPT_EXPECT_100_TIMEOUT_MS,
+ (long)(config->expect100timeout*1000));
+
+ /* new in 7.48.0 */
+ if(config->tftp_no_options)
+ my_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
+
/* initialize retry vars for loop below */
retry_sleep_default = (config->retry_delay) ?
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
retrystart = tvnow();
#ifndef CURL_DISABLE_LIBCURL_OPTION
- result = easysrc_perform();
- if(result) {
- goto show_error;
+ if(global->libcurl) {
+ result = easysrc_perform();
+ if(result)
+ goto show_error;
}
#endif
#endif
result = curl_easy_perform(curl);
+ if(!result && !outs.stream && !outs.bytes) {
+ /* we have received no data despite the transfer was successful
+ ==> force cration of an empty output file (if an output file
+ was specified) */
+ long cond_unmet = 0L;
+ /* do not create (or even overwrite) the file in case we get no
+ data because of unmet condition */
+ curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &cond_unmet);
+ if(!cond_unmet && !tool_create_output_file(&outs))
+ result = CURLE_WRITE_ERROR;
+ }
+
if(outs.is_cd_filename && outs.stream && !global->mute &&
outs.filename)
printf("curl: Saved to filename '%s'\n", outs.filename);
static const char * const m[]={
NULL, "timeout", "HTTP error", "FTP error"
};
- warnf(config, "Transient problem: %s "
+
+ warnf(config->global, "Transient problem: %s "
"Will retry in %ld seconds. "
"%ld retries left.\n",
m[retry], retry_sleep/1000L, retry_numretries);
if(retry_sleep > RETRY_SLEEP_MAX)
retry_sleep = RETRY_SLEEP_MAX;
}
- if(outs.bytes && outs.filename) {
+ if(outs.bytes && outs.filename && outs.stream) {
/* We have written data to a output file, we truncate file
*/
if(!global->mute)
if(!result && config->xattr && outs.fopened && outs.stream) {
int rc = fwrite_xattr(curl, fileno(outs.stream));
if(rc)
- warnf(config, "Error setting extended attributes: %s\n",
+ warnf(config->global, "Error setting extended attributes: %s\n",
strerror(errno));
}
/* Check if we were asked to list the SSL engines */
else if(res == PARAM_ENGINES_REQUESTED)
tool_list_engines(config->easy);
+ else if(res == PARAM_LIBCURL_UNSUPPORTED_PROTOCOL)
+ result = CURLE_UNSUPPORTED_PROTOCOL;
else
result = CURLE_FAILED_INIT;
}
else {
#ifndef CURL_DISABLE_LIBCURL_OPTION
- /* Initialise the libcurl source output */
- result = easysrc_init();
+ if(config->libcurl) {
+ /* Initialise the libcurl source output */
+ result = easysrc_init();
+ }
#endif
/* Perform the main operations */
}
#ifndef CURL_DISABLE_LIBCURL_OPTION
- /* Cleanup the libcurl source output */
- easysrc_cleanup();
-
- /* set current back to first so that isn't NULL */
- config->current = config->first;
+ if(config->libcurl) {
+ /* Cleanup the libcurl source output */
+ easysrc_cleanup();
- /* Dump the libcurl code if previously enabled */
- dumpeasysrc(config);
+ /* Dump the libcurl code if previously enabled */
+ dumpeasysrc(config);
+ }
#endif
}
else