25 #ifdef HAVE_NETINET_IN_H
26 #include <netinet/in.h>
31 #ifdef HAVE_ARPA_INET_H
32 #include <arpa/inet.h>
37 #ifdef HAVE_SYS_IOCTL_H
38 #include <sys/ioctl.h>
41 #ifdef HAVE_SYS_PARAM_H
42 #include <sys/param.h>
55 #error "We can't compile without socket() support!"
65 #elif defined(USE_WIN32_IDN)
67 bool curl_win32_idn_to_ascii(
const char *in,
char **out);
137 char **userptr,
char **passwdptr,
140 char **userptr,
char **passwdptr,
144 #define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
145 #define READBUFFER_MAX CURL_MAX_READ_SIZE
146 #define READBUFFER_MIN 1024
152 #if READBUFFER_SIZE < READBUFFER_MIN
153 # error READBUFFER_SIZE is too small
163 #ifndef CURL_DISABLE_HTTP
167 #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
171 #ifndef CURL_DISABLE_FTP
175 #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
179 #ifndef CURL_DISABLE_TELNET
183 #ifndef CURL_DISABLE_DICT
187 #ifndef CURL_DISABLE_LDAP
189 #if !defined(CURL_DISABLE_LDAPS) && \
190 ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
191 (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
196 #ifndef CURL_DISABLE_FILE
200 #ifndef CURL_DISABLE_TFTP
209 #ifndef CURL_DISABLE_IMAP
216 #ifndef CURL_DISABLE_POP3
223 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
224 (CURL_SIZEOF_CURL_OFF_T > 4) && \
225 (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
232 #ifndef CURL_DISABLE_SMTP
239 #ifndef CURL_DISABLE_RTSP
243 #ifndef CURL_DISABLE_GOPHER
251 &Curl_handler_rtmpte,
253 &Curl_handler_rtmpts,
292 if(
data->change.referer_alloc) {
296 data->change.referer = NULL;
297 if(
data->change.url_alloc) {
301 data->change.url = NULL;
333 (userp ? &user : NULL),
334 (passwdp ? &passwd : NULL),
341 if(!user && option && option[0] ==
':') {
435 if(
data->state.rangestringalloc)
440 data->state.path = NULL;
453 data->req.newurl = NULL;
455 if(
data->change.referer_alloc) {
459 data->change.referer = NULL;
461 if(
data->change.url_alloc) {
465 data->change.url = NULL;
488 data->share->dirty--;
492 if(
data->set.wildcardmatch) {
520 set->is_fread_set = 0;
521 set->is_fwrite_set = 0;
532 set->postfieldsize = -1;
542 set->dns_cache_timeout = 60;
545 set->general_ssl.max_ssl_sessions = 5;
562 set->ssl.primary.verifypeer =
TRUE;
563 set->ssl.primary.verifyhost =
TRUE;
569 set->ssl.primary.sessionid =
TRUE;
571 set->proxy_ssl =
set->ssl;
573 set->new_file_perms = 0644;
574 set->new_directory_perms = 0755;
584 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
593 #if defined(CURL_CA_BUNDLE)
602 #if defined(CURL_CA_PATH)
620 set->tcp_keepintvl = 60;
621 set->tcp_keepidle = 60;
628 set->expect_100_timeout = 1000L;
653 DEBUGF(
fprintf(stderr,
"Error: calloc of Curl_easy failed\n"));
669 if(!
data->state.buffer) {
677 if(!
data->state.headerbuff) {
678 DEBUGF(
fprintf(stderr,
"Error: malloc of headerbuff failed\n"));
691 data->state.lastconnect = NULL;
694 data->state.current_speed = -1;
715 #define C_SSLVERSION_VALUE(x) (x & 0xffff)
716 #define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
724 #ifndef CURL_DISABLE_HTTP
729 case CURLOPT_DNS_CACHE_TIMEOUT:
730 data->set.dns_cache_timeout = va_arg(
param,
long);
732 case CURLOPT_DNS_USE_GLOBAL_CACHE:
734 arg = va_arg(
param,
long);
737 case CURLOPT_SSL_CIPHER_LIST:
740 va_arg(
param,
char *));
742 case CURLOPT_PROXY_SSL_CIPHER_LIST:
745 va_arg(
param,
char *));
748 case CURLOPT_RANDOM_FILE:
754 va_arg(
param,
char *));
756 case CURLOPT_EGDSOCKET:
761 va_arg(
param,
char *));
763 case CURLOPT_MAXCONNECTS:
768 data->set.maxconnects = va_arg(
param,
long);
770 case CURLOPT_FORBID_REUSE:
777 case CURLOPT_FRESH_CONNECT:
784 case CURLOPT_VERBOSE:
797 case CURLOPT_NOPROGRESS:
802 if(
data->set.hide_progress)
813 case CURLOPT_FAILONERROR:
820 case CURLOPT_KEEP_SENDING_ON_ERROR:
821 data->set.http_keep_sending_on_error = (0 != va_arg(
param,
long)) ?
831 if(
data->set.upload) {
841 case CURLOPT_REQUEST_TARGET:
843 va_arg(
param,
char *));
845 case CURLOPT_FILETIME:
852 case CURLOPT_FTP_CREATE_MISSING_DIRS:
857 switch(va_arg(
param,
long)) {
859 data->set.ftp_create_missing_dirs = 0;
862 data->set.ftp_create_missing_dirs = 1;
865 data->set.ftp_create_missing_dirs = 2;
878 data->set.server_response_timeout = va_arg(
param,
long) * 1000;
880 case CURLOPT_TFTP_NO_OPTIONS:
885 data->set.tftp_no_options = va_arg(
param,
long) != 0;
887 case CURLOPT_TFTP_BLKSIZE:
891 data->set.tftp_blksize = va_arg(
param,
long);
893 case CURLOPT_DIRLISTONLY:
906 case CURLOPT_FTP_FILEMETHOD:
918 case CURLOPT_NETRC_FILE:
923 va_arg(
param,
char *));
925 case CURLOPT_TRANSFERTEXT:
934 case CURLOPT_TIMECONDITION:
941 case CURLOPT_TIMEVALUE:
946 data->set.timevalue = (time_t)va_arg(
param,
long);
948 case CURLOPT_SSLVERSION:
954 arg = va_arg(
param,
long);
961 case CURLOPT_PROXY_SSLVERSION:
967 arg = va_arg(
param,
long);
975 #ifndef CURL_DISABLE_HTTP
976 case CURLOPT_AUTOREFERER:
983 case CURLOPT_ACCEPT_ENCODING:
993 argptr = va_arg(
param,
char *);
995 (argptr && !*argptr)?
999 case CURLOPT_TRANSFER_ENCODING:
1000 data->set.http_transfer_encoding = (0 != va_arg(
param,
long)) ?
1004 case CURLOPT_FOLLOWLOCATION:
1011 case CURLOPT_UNRESTRICTED_AUTH:
1016 data->set.http_disable_hostname_check_before_authentication =
1020 case CURLOPT_MAXREDIRS:
1025 data->set.maxredirs = va_arg(
param,
long);
1028 case CURLOPT_POSTREDIR:
1039 arg = va_arg(
param,
long);
1048 if(va_arg(
param,
long)) {
1056 case CURLOPT_COPYPOSTFIELDS:
1062 argptr = va_arg(
param,
char *);
1064 if(!argptr ||
data->set.postfieldsize == -1)
1071 if((
data->set.postfieldsize < 0) ||
1086 data->set.postfieldsize:1));
1091 if(
data->set.postfieldsize)
1092 memcpy(
p, argptr, (
size_t)
data->set.postfieldsize);
1103 case CURLOPT_POSTFIELDS:
1107 data->set.postfields = va_arg(
param,
void *);
1113 case CURLOPT_POSTFIELDSIZE:
1118 bigsize = va_arg(
param,
long);
1120 if(
data->set.postfieldsize < bigsize &&
1124 data->set.postfields = NULL;
1127 data->set.postfieldsize = bigsize;
1130 case CURLOPT_POSTFIELDSIZE_LARGE:
1137 if(
data->set.postfieldsize < bigsize &&
1141 data->set.postfields = NULL;
1144 data->set.postfieldsize = bigsize;
1147 case CURLOPT_HTTPPOST:
1157 case CURLOPT_MIMEPOST:
1164 data->set.mimepost.freefunc = NULL;
1170 case CURLOPT_REFERER:
1174 if(
data->change.referer_alloc) {
1179 va_arg(
param,
char *));
1183 case CURLOPT_USERAGENT:
1188 va_arg(
param,
char *));
1191 case CURLOPT_HTTPHEADER:
1198 #ifndef CURL_DISABLE_HTTP
1199 case CURLOPT_PROXYHEADER:
1213 case CURLOPT_HEADEROPT:
1217 arg = va_arg(
param,
long);
1221 case CURLOPT_HTTP200ALIASES:
1228 #if !defined(CURL_DISABLE_COOKIES)
1229 case CURLOPT_COOKIE:
1234 va_arg(
param,
char *));
1237 case CURLOPT_COOKIEFILE:
1241 argptr = (
char *)va_arg(
param,
void *);
1249 data->change.cookielist = NULL;
1252 data->change.cookielist = cl;
1256 case CURLOPT_COOKIEJAR:
1263 va_arg(
param,
char *));
1270 data->set.cookiesession);
1273 data->cookies = newcookies;
1277 case CURLOPT_COOKIESESSION:
1296 case CURLOPT_COOKIELIST:
1297 argptr = va_arg(
param,
char *);
1329 if(!argptr || !
data->cookies) {
1352 case CURLOPT_HTTPGET:
1356 if(va_arg(
param,
long)) {
1363 case CURLOPT_HTTP_VERSION:
1368 arg = va_arg(
param,
long);
1373 data->set.httpversion = arg;
1376 case CURLOPT_EXPECT_100_TIMEOUT_MS:
1381 data->set.expect_100_timeout = va_arg(
param,
long);
1386 case CURLOPT_HTTPAUTH:
1393 unsigned long auth = va_arg(
param,
unsigned long);
1413 #elif !defined(NTLM_WB_ENABLED)
1424 while(bitcheck < 31) {
1425 if(
auth & (1UL << bitcheck++)) {
1437 case CURLOPT_CUSTOMREQUEST:
1442 va_arg(
param,
char *));
1450 #ifndef CURL_DISABLE_PROXY
1451 case CURLOPT_HTTPPROXYTUNNEL:
1455 data->set.tunnel_thru_httpproxy = (0 != va_arg(
param,
long)) ?
1459 case CURLOPT_PROXYPORT:
1463 data->set.proxyport = va_arg(
param,
long);
1466 case CURLOPT_PROXYAUTH:
1473 unsigned long auth = va_arg(
param,
unsigned long);
1492 #elif !defined(NTLM_WB_ENABLED)
1503 while(bitcheck < 31) {
1504 if(
auth & (1UL << bitcheck++)) {
1528 va_arg(
param,
char *));
1531 case CURLOPT_PRE_PROXY:
1539 va_arg(
param,
char *));
1542 case CURLOPT_PROXYTYPE:
1549 case CURLOPT_PROXY_TRANSFER_MODE:
1553 switch(va_arg(
param,
long)) {
1558 data->set.proxy_transfer_mode =
TRUE;
1568 case CURLOPT_SOCKS5_AUTH:
1569 data->set.socks5auth = va_arg(
param,
unsigned long);
1573 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1574 case CURLOPT_SOCKS5_GSSAPI_NEC:
1581 case CURLOPT_SOCKS5_GSSAPI_SERVICE:
1582 case CURLOPT_PROXY_SERVICE_NAME:
1587 va_arg(
param,
char *));
1591 #if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
1593 case CURLOPT_SERVICE_NAME:
1598 va_arg(
param,
char *));
1603 case CURLOPT_HEADERDATA:
1607 data->set.writeheader = (
void *)va_arg(
param,
void *);
1609 case CURLOPT_ERRORBUFFER:
1614 data->set.errorbuffer = va_arg(
param,
char *);
1616 case CURLOPT_WRITEDATA:
1623 case CURLOPT_FTPPORT:
1628 va_arg(
param,
char *));
1632 case CURLOPT_FTP_USE_EPRT:
1636 case CURLOPT_FTP_USE_EPSV:
1640 case CURLOPT_FTP_USE_PRET:
1644 case CURLOPT_FTP_SSL_CCC:
1648 case CURLOPT_FTP_SKIP_PASV_IP:
1656 case CURLOPT_READDATA:
1661 data->set.in_set = va_arg(
param,
void *);
1663 case CURLOPT_INFILESIZE:
1668 data->set.filesize = va_arg(
param,
long);
1670 case CURLOPT_INFILESIZE_LARGE:
1677 case CURLOPT_LOW_SPEED_LIMIT:
1682 data->set.low_speed_limit = va_arg(
param,
long);
1684 case CURLOPT_MAX_SEND_SPEED_LARGE:
1691 case CURLOPT_MAX_RECV_SPEED_LARGE:
1698 case CURLOPT_LOW_SPEED_TIME:
1703 data->set.low_speed_time = va_arg(
param,
long);
1709 if(
data->change.url_alloc) {
1715 va_arg(
param,
char *));
1722 data->set.use_port = va_arg(
param,
long);
1724 case CURLOPT_TIMEOUT:
1729 data->set.timeout = va_arg(
param,
long) * 1000L;
1732 case CURLOPT_TIMEOUT_MS:
1733 data->set.timeout = va_arg(
param,
long);
1736 case CURLOPT_CONNECTTIMEOUT:
1740 data->set.connecttimeout = va_arg(
param,
long) * 1000L;
1743 case CURLOPT_CONNECTTIMEOUT_MS:
1744 data->set.connecttimeout = va_arg(
param,
long);
1747 case CURLOPT_ACCEPTTIMEOUT_MS:
1751 data->set.accepttimeout = va_arg(
param,
long);
1754 case CURLOPT_USERPWD:
1763 case CURLOPT_USERNAME:
1768 va_arg(
param,
char *));
1771 case CURLOPT_PASSWORD:
1776 va_arg(
param,
char *));
1779 case CURLOPT_LOGIN_OPTIONS:
1784 va_arg(
param,
char *));
1787 case CURLOPT_XOAUTH2_BEARER:
1792 va_arg(
param,
char *));
1795 case CURLOPT_POSTQUOTE:
1801 case CURLOPT_PREQUOTE:
1813 case CURLOPT_RESOLVE:
1825 data->change.resolve =
data->set.resolve;
1827 case CURLOPT_PROGRESSFUNCTION:
1832 if(
data->set.fprogress)
1838 case CURLOPT_XFERINFOFUNCTION:
1843 if(
data->set.fxferinfo)
1850 case CURLOPT_PROGRESSDATA:
1854 data->set.progress_client = va_arg(
param,
void *);
1857 #ifndef CURL_DISABLE_PROXY
1858 case CURLOPT_PROXYUSERPWD:
1866 case CURLOPT_PROXYUSERNAME:
1871 va_arg(
param,
char *));
1873 case CURLOPT_PROXYPASSWORD:
1878 va_arg(
param,
char *));
1880 case CURLOPT_NOPROXY:
1885 va_arg(
param,
char *));
1894 va_arg(
param,
char *));
1896 case CURLOPT_RESUME_FROM:
1900 data->set.set_resume_from = va_arg(
param,
long);
1902 case CURLOPT_RESUME_FROM_LARGE:
1908 case CURLOPT_DEBUGFUNCTION:
1917 case CURLOPT_DEBUGDATA:
1922 data->set.debugdata = va_arg(
param,
void *);
1924 case CURLOPT_STDERR:
1931 data->set.err = stderr;
1933 case CURLOPT_HEADERFUNCTION:
1939 case CURLOPT_WRITEFUNCTION:
1944 if(!
data->set.fwrite_func) {
1945 data->set.is_fwrite_set = 0;
1950 data->set.is_fwrite_set = 1;
1952 case CURLOPT_READFUNCTION:
1957 if(!
data->set.fread_func_set) {
1958 data->set.is_fread_set = 0;
1963 data->set.is_fread_set = 1;
1965 case CURLOPT_SEEKFUNCTION:
1971 case CURLOPT_SEEKDATA:
1975 data->set.seek_client = va_arg(
param,
void *);
1977 case CURLOPT_CONV_FROM_NETWORK_FUNCTION:
1983 case CURLOPT_CONV_TO_NETWORK_FUNCTION:
1989 case CURLOPT_CONV_FROM_UTF8_FUNCTION:
1995 case CURLOPT_IOCTLFUNCTION:
2001 case CURLOPT_IOCTLDATA:
2005 data->set.ioctl_client = va_arg(
param,
void *);
2007 case CURLOPT_SSLCERT:
2012 va_arg(
param,
char *));
2014 case CURLOPT_PROXY_SSLCERT:
2019 va_arg(
param,
char *));
2021 case CURLOPT_SSLCERTTYPE:
2026 va_arg(
param,
char *));
2028 case CURLOPT_PROXY_SSLCERTTYPE:
2033 va_arg(
param,
char *));
2035 case CURLOPT_SSLKEY:
2040 va_arg(
param,
char *));
2042 case CURLOPT_PROXY_SSLKEY:
2047 va_arg(
param,
char *));
2049 case CURLOPT_SSLKEYTYPE:
2054 va_arg(
param,
char *));
2056 case CURLOPT_PROXY_SSLKEYTYPE:
2061 va_arg(
param,
char *));
2063 case CURLOPT_KEYPASSWD:
2068 va_arg(
param,
char *));
2070 case CURLOPT_PROXY_KEYPASSWD:
2075 va_arg(
param,
char *));
2077 case CURLOPT_SSLENGINE:
2081 argptr = va_arg(
param,
char *);
2082 if(argptr && argptr[0])
2086 case CURLOPT_SSLENGINE_DEFAULT:
2099 case CURLOPT_INTERFACE:
2105 va_arg(
param,
char *));
2107 case CURLOPT_LOCALPORT:
2111 arg = va_arg(
param,
long);
2112 if((arg < 0) || (arg > 65535))
2116 case CURLOPT_LOCALPORTRANGE:
2120 arg = va_arg(
param,
long);
2121 if((arg < 0) || (arg > 65535))
2125 case CURLOPT_KRBLEVEL:
2130 va_arg(
param,
char *));
2133 case CURLOPT_GSSAPI_DELEGATION:
2137 data->set.gssapi_delegation = va_arg(
param,
long);
2139 case CURLOPT_SSL_VERIFYPEER:
2143 data->set.ssl.primary.verifypeer = (0 != va_arg(
param,
long)) ?
2146 case CURLOPT_PROXY_SSL_VERIFYPEER:
2150 data->set.proxy_ssl.primary.verifypeer =
2153 case CURLOPT_SSL_VERIFYHOST:
2157 arg = va_arg(
param,
long);
2165 failf(
data,
"CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
2169 data->set.ssl.primary.verifyhost = (0 != arg) ?
TRUE :
FALSE;
2171 case CURLOPT_PROXY_SSL_VERIFYHOST:
2175 arg = va_arg(
param,
long);
2183 failf(
data,
"CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
2187 data->set.proxy_ssl.primary.verifyhost = (0 != arg)?
TRUE:
FALSE;
2189 case CURLOPT_SSL_VERIFYSTATUS:
2198 data->set.ssl.primary.verifystatus = (0 != va_arg(
param,
long)) ?
2201 case CURLOPT_SSL_CTX_FUNCTION:
2212 case CURLOPT_SSL_CTX_DATA:
2218 data->set.ssl.fsslctxp = va_arg(
param,
void *);
2223 case CURLOPT_SSL_FALSESTART:
2234 case CURLOPT_CERTINFO:
2242 case CURLOPT_PINNEDPUBLICKEY:
2250 va_arg(
param,
char *));
2255 case CURLOPT_PROXY_PINNEDPUBLICKEY:
2263 va_arg(
param,
char *));
2268 case CURLOPT_CAINFO:
2273 va_arg(
param,
char *));
2275 case CURLOPT_PROXY_CAINFO:
2281 va_arg(
param,
char *));
2283 case CURLOPT_CAPATH:
2292 va_arg(
param,
char *));
2297 case CURLOPT_PROXY_CAPATH:
2306 va_arg(
param,
char *));
2311 case CURLOPT_CRLFILE:
2317 va_arg(
param,
char *));
2319 case CURLOPT_PROXY_CRLFILE:
2325 va_arg(
param,
char *));
2327 case CURLOPT_ISSUERCERT:
2333 va_arg(
param,
char *));
2335 case CURLOPT_TELNETOPTIONS:
2342 case CURLOPT_BUFFERSIZE:
2347 arg = va_arg(
param,
long);
2357 if(arg !=
data->set.buffer_size) {
2358 char *newbuff =
realloc(
data->state.buffer, arg + 1);
2360 DEBUGF(
fprintf(stderr,
"Error: realloc of buffer failed\n"));
2364 data->state.buffer = newbuff;
2366 data->set.buffer_size = arg;
2370 case CURLOPT_NOSIGNAL:
2387 if(
data->dns.hostcachetype == HCACHE_SHARED) {
2388 data->dns.hostcache = NULL;
2389 data->dns.hostcachetype = HCACHE_NONE;
2392 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
2393 if(
data->share->cookies ==
data->cookies)
2394 data->cookies = NULL;
2397 if(
data->share->sslsession ==
data->state.session)
2398 data->state.session = NULL;
2400 data->share->dirty--;
2412 data->share->dirty++;
2416 data->dns.hostcache = &
data->share->hostcache;
2417 data->dns.hostcachetype = HCACHE_SHARED;
2419 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
2420 if(
data->share->cookies) {
2424 data->cookies =
data->share->cookies;
2427 if(
data->share->sslsession) {
2428 data->set.general_ssl.max_ssl_sessions =
data->share->max_ssl_sessions;
2429 data->state.session =
data->share->sslsession;
2439 case CURLOPT_PRIVATE:
2443 data->set.private_data = va_arg(
param,
void *);
2446 case CURLOPT_MAXFILESIZE:
2450 data->set.max_filesize = va_arg(
param,
long);
2454 case CURLOPT_USE_SSL:
2461 case CURLOPT_SSL_OPTIONS:
2462 arg = va_arg(
param,
long);
2467 case CURLOPT_PROXY_SSL_OPTIONS:
2468 arg = va_arg(
param,
long);
2474 case CURLOPT_FTPSSLAUTH:
2481 case CURLOPT_IPRESOLVE:
2485 case CURLOPT_MAXFILESIZE_LARGE:
2492 case CURLOPT_TCP_NODELAY:
2500 case CURLOPT_FTP_ACCOUNT:
2502 va_arg(
param,
char *));
2505 case CURLOPT_IGNORE_CONTENT_LENGTH:
2509 case CURLOPT_CONNECT_ONLY:
2516 case CURLOPT_FTP_ALTERNATIVE_TO_USER:
2518 va_arg(
param,
char *));
2521 case CURLOPT_SOCKOPTFUNCTION:
2528 case CURLOPT_SOCKOPTDATA:
2532 data->set.sockopt_client = va_arg(
param,
void *);
2535 case CURLOPT_OPENSOCKETFUNCTION:
2543 case CURLOPT_OPENSOCKETDATA:
2547 data->set.opensocket_client = va_arg(
param,
void *);
2550 case CURLOPT_CLOSESOCKETFUNCTION:
2558 case CURLOPT_CLOSESOCKETDATA:
2562 data->set.closesocket_client = va_arg(
param,
void *);
2565 case CURLOPT_SSL_SESSIONID_CACHE:
2566 data->set.ssl.primary.sessionid = (0 != va_arg(
param,
long)) ?
2568 data->set.proxy_ssl.primary.sessionid =
data->set.ssl.primary.sessionid;
2573 case CURLOPT_SSH_AUTH_TYPES:
2574 data->set.ssh_auth_types = va_arg(
param,
long);
2577 case CURLOPT_SSH_PUBLIC_KEYFILE:
2582 va_arg(
param,
char *));
2585 case CURLOPT_SSH_PRIVATE_KEYFILE:
2590 va_arg(
param,
char *));
2592 case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
2598 va_arg(
param,
char *));
2600 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
2601 case CURLOPT_SSH_KNOWNHOSTS:
2606 va_arg(
param,
char *));
2609 case CURLOPT_SSH_KEYFUNCTION:
2615 case CURLOPT_SSH_KEYDATA:
2619 data->set.ssh_keyfunc_userp = va_arg(
param,
void *);
2625 case CURLOPT_HTTP_TRANSFER_DECODING:
2632 case CURLOPT_HTTP_CONTENT_DECODING:
2639 case CURLOPT_NEW_FILE_PERMS:
2643 data->set.new_file_perms = va_arg(
param,
long);
2646 case CURLOPT_NEW_DIRECTORY_PERMS:
2650 data->set.new_directory_perms = va_arg(
param,
long);
2653 case CURLOPT_ADDRESS_SCOPE:
2659 arg = va_arg(
param,
long);
2660 if((arg < 0) || (arg > 0xf))
2665 case CURLOPT_PROTOCOLS:
2670 data->set.allowed_protocols = va_arg(
param,
long);
2673 case CURLOPT_REDIR_PROTOCOLS:
2678 data->set.redir_protocols = va_arg(
param,
long);
2681 case CURLOPT_DEFAULT_PROTOCOL:
2684 va_arg(
param,
char *));
2687 case CURLOPT_MAIL_FROM:
2690 va_arg(
param,
char *));
2693 case CURLOPT_MAIL_AUTH:
2696 va_arg(
param,
char *));
2699 case CURLOPT_MAIL_RCPT:
2704 case CURLOPT_SASL_IR:
2709 case CURLOPT_RTSP_REQUEST:
2715 long curl_rtspreq = va_arg(
param,
long);
2717 switch(curl_rtspreq) {
2765 data->set.rtspreq = rtspreq;
2770 case CURLOPT_RTSP_SESSION_ID:
2776 va_arg(
param,
char *));
2779 case CURLOPT_RTSP_STREAM_URI:
2785 va_arg(
param,
char *));
2788 case CURLOPT_RTSP_TRANSPORT:
2793 va_arg(
param,
char *));
2796 case CURLOPT_RTSP_CLIENT_CSEQ:
2802 data->state.rtsp_next_client_CSeq = va_arg(
param,
long);
2805 case CURLOPT_RTSP_SERVER_CSEQ:
2807 data->state.rtsp_next_client_CSeq = va_arg(
param,
long);
2810 case CURLOPT_INTERLEAVEDATA:
2811 data->set.rtp_out = va_arg(
param,
void *);
2813 case CURLOPT_INTERLEAVEFUNCTION:
2818 case CURLOPT_WILDCARDMATCH:
2821 case CURLOPT_CHUNK_BGN_FUNCTION:
2824 case CURLOPT_CHUNK_END_FUNCTION:
2827 case CURLOPT_FNMATCH_FUNCTION:
2830 case CURLOPT_CHUNK_DATA:
2831 data->wildcard.customptr = va_arg(
param,
void *);
2833 case CURLOPT_FNMATCH_DATA:
2834 data->set.fnmatch_data = va_arg(
param,
void *);
2837 case CURLOPT_TLSAUTH_USERNAME:
2839 va_arg(
param,
char *));
2840 if(
data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !
data->set.ssl.authtype)
2843 case CURLOPT_PROXY_TLSAUTH_USERNAME:
2845 va_arg(
param,
char *));
2846 if(
data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2847 !
data->set.proxy_ssl.authtype)
2850 case CURLOPT_TLSAUTH_PASSWORD:
2852 va_arg(
param,
char *));
2853 if(
data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !
data->set.ssl.authtype)
2856 case CURLOPT_PROXY_TLSAUTH_PASSWORD:
2858 va_arg(
param,
char *));
2859 if(
data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2860 !
data->set.proxy_ssl.authtype)
2863 case CURLOPT_TLSAUTH_TYPE:
2864 argptr = va_arg(
param,
char *);
2871 case CURLOPT_PROXY_TLSAUTH_TYPE:
2872 argptr = va_arg(
param,
char *);
2880 case CURLOPT_DNS_SERVERS:
2883 case CURLOPT_DNS_INTERFACE:
2886 case CURLOPT_DNS_LOCAL_IP4:
2889 case CURLOPT_DNS_LOCAL_IP6:
2893 case CURLOPT_TCP_KEEPALIVE:
2896 case CURLOPT_TCP_KEEPIDLE:
2897 data->set.tcp_keepidle = va_arg(
param,
long);
2899 case CURLOPT_TCP_KEEPINTVL:
2900 data->set.tcp_keepintvl = va_arg(
param,
long);
2902 case CURLOPT_TCP_FASTOPEN:
2903 #if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN)
2909 case CURLOPT_SSL_ENABLE_NPN:
2912 case CURLOPT_SSL_ENABLE_ALPN:
2916 #ifdef USE_UNIX_SOCKETS
2917 case CURLOPT_UNIX_SOCKET_PATH:
2920 va_arg(
param,
char *));
2922 case CURLOPT_ABSTRACT_UNIX_SOCKET:
2923 data->set.abstract_unix_socket =
TRUE;
2925 va_arg(
param,
char *));
2929 case CURLOPT_PATH_AS_IS:
2932 case CURLOPT_PIPEWAIT:
2935 case CURLOPT_STREAM_WEIGHT:
2939 arg = va_arg(
param,
long);
2940 if((arg >= 1) && (arg <= 256))
2941 data->set.stream_weight = (int)arg;
2944 case CURLOPT_STREAM_DEPENDS:
2945 case CURLOPT_STREAM_DEPENDS_E:
2952 if(
data->set.stream_depends_on) {
2960 case CURLOPT_CONNECT_TO:
2963 case CURLOPT_SUPPRESS_CONNECT_HEADERS:
2966 case CURLOPT_SSH_COMPRESSION:
2978 #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
2979 static void conn_reset_postponed_data(
struct connectdata *conn,
int num)
2981 struct postponed_data *
const psnd = &(conn->postponed[num]);
2984 DEBUGASSERT(psnd->recv_size <= psnd->allocated_size);
2986 (psnd->recv_processed < psnd->recv_size) :
2987 (psnd->recv_processed == 0));
2990 psnd->buffer = NULL;
2991 psnd->allocated_size = 0;
2992 psnd->recv_size = 0;
2993 psnd->recv_processed = 0;
3008 conn_reset_postponed_data(conn, 0);
3009 conn_reset_postponed_data(conn, 1);
3013 #define conn_reset_all_postponed_data(c) do {} WHILE_FALSE
3039 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
3040 defined(NTLM_WB_ENABLED)
3041 Curl_ntlm_wb_cleanup(conn);
3080 #ifdef USE_UNIX_SOCKETS
3105 DEBUGF(
fprintf(stderr,
"DISCONNECT without easy handle, ignoring\n"));
3127 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM)
3129 Curl_http_ntlm_cleanup(conn);
3166 bool ret_val =
TRUE;
3212 curr = pipeline->
head;
3214 if(curr->
ptr == handle) {
3226 static void Curl_printPipeline(
struct curl_llist *pipeline)
3230 curr = pipeline->
head;
3272 curr = pipeline->
head;
3280 infof(
data,
"signalPipeClose() found BAAD easy handle\n");
3306 time_t highscore =- 1;
3330 if(score > highscore) {
3332 conn_candidate = conn;
3341 return conn_candidate;
3369 time_t highscore = -1;
3387 if(score > highscore) {
3389 conn_candidate = conn;
3395 return conn_candidate;
3408 if(!pipeLen && !conn->
inuse) {
3462 if(elapsed >= 1000L) {
3465 data->state.conn_cache->last_cleanup =
now;
3497 bool foundPendingCandidate =
FALSE;
3502 bool wantNTLMhttp = ((
data->state.authhost.want &
3506 ((
data->state.authproxy.want &
3511 *force_reuse =
FALSE;
3526 size_t best_pipe_len = max_pipe_len;
3529 infof(
data,
"Found bundle for host %s: %p [%s]\n",
3531 needle->
host.
name), (
void *)bundle,
3535 "can multiplex" :
"serially")));
3541 infof(
data,
"Server doesn't support multi-use yet, wait\n");
3546 infof(
data,
"Server doesn't support multi-use (yet)\n");
3552 infof(
data,
"Could pipeline, but not asked to!\n");
3557 infof(
data,
"Could multiplex, but not asked to!\n");
3562 curr = bundle->conn_list.head;
3577 pipeLen =
check->send_pipe.size +
check->recv_pipe.size;
3580 if(
check->bits.protoconnstart &&
check->bits.close)
3583 if(!
check->bits.multiplex) {
3608 if(!
check->ip_addr_str[0]) {
3610 "Connection #%ld is still name resolving, can't reuse\n",
3611 check->connection_id);
3617 check->bits.close) {
3618 if(!
check->bits.close)
3619 foundPendingCandidate =
TRUE;
3622 infof(
data,
"Connection #%ld isn't open enough, can't reuse\n",
3623 check->connection_id);
3625 if(
check->recv_pipe.size > 0) {
3627 "BAD! Unconnected #%ld has a non-empty recv pipeline!\n",
3628 check->connection_id);
3635 #ifdef USE_UNIX_SOCKETS
3636 if(needle->unix_domain_socket) {
3637 if(!
check->unix_domain_socket)
3639 if(strcmp(needle->unix_domain_socket,
check->unix_domain_socket))
3641 if(needle->abstract_unix_socket !=
check->abstract_unix_socket)
3644 else if(
check->unix_domain_socket)
3661 &
check->socks_proxy))
3686 &
check->proxy_ssl_config))
3693 &
check->ssl_config))
3701 if(!canpipe &&
check->inuse)
3757 &
check->ssl_config)) {
3759 "Connection #%ld has different SSL parameters, "
3761 check->connection_id));
3765 foundPendingCandidate =
TRUE;
3767 "Connection #%ld has not started SSL connect, "
3769 check->connection_id));
3783 #if defined(USE_NTLM)
3800 if(wantProxyNTLMhttp) {
3803 if(!
check->http_proxy.user || !
check->http_proxy.passwd)
3815 if(wantNTLMhttp || wantProxyNTLMhttp) {
3821 (wantProxyNTLMhttp &&
3824 *force_reuse =
TRUE;
3844 if(max_pipe_len && (pipeLen >= max_pipe_len)) {
3845 infof(
data,
"Pipe is full, skip (%zu)\n", pipeLen);
3850 if(
check->bits.multiplex) {
3853 if(pipeLen >= httpc->settings.max_concurrent_streams) {
3854 infof(
data,
"MAX_CONCURRENT_STREAMS reached, skip (%zu)\n",
3867 if(pipeLen < best_pipe_len) {
3871 best_pipe_len = pipeLen;
3878 infof(
data,
"Multiplexed connection found!\n");
3896 if(foundPendingCandidate &&
data->set.pipewait) {
3898 "Found pending candidate for reuse and CURLOPT_PIPEWAIT is set\n");
3916 #ifndef CURL_DISABLE_PROXY
3935 host,
port, sockindex, conn);
3945 failf(conn->
data,
"unknown proxytype option given");
3960 #ifndef CURL_DISABLE_VERBOSE_STRINGS
3964 infof(conn->
data,
"Connected to %s (%s) port %ld (#%ld)\n",
4037 bool *protocol_done)
4041 *protocol_done =
FALSE;
4051 *protocol_done =
TRUE;
4079 *protocol_done =
TRUE;
4095 const unsigned char *ch = (
const unsigned char *)
hostname;
4115 #elif defined(CURL_DISABLE_VERBOSE_STRINGS)
4131 if(idn2_check_version(IDN2_VERSION)) {
4132 char *ace_hostname = NULL;
4133 #if IDN2_VERSION_NUMBER >= 0x00140000
4137 int flags = IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL;
4139 int flags = IDN2_NFC_INPUT;
4141 int rc = idn2_lookup_ul((
const char *)host->
name, &ace_hostname, flags);
4143 host->
encalloc = (
char *)ace_hostname;
4148 infof(
data,
"Failed to convert %s to ACE; %s\n", host->
name,
4151 #elif defined(USE_WIN32_IDN)
4152 char *ace_hostname = NULL;
4154 if(curl_win32_idn_to_ascii(host->
name, &ace_hostname)) {
4162 infof(
data,
"IDN support not present, can't parse Unicode domains\n");
4172 #if defined(USE_LIBIDN2)
4178 #elif defined(USE_WIN32_IDN)
4200 #define SSL_EXTRA + 4 * Curl_ssl->sizeof_ssl_backend_data - sizeof(long long)
4221 #if defined(USE_RECV_BEFORE_SEND_WORKAROUND) && defined(DEBUGBUILD)
4229 connclose(conn,
"Default to force-close");
4240 #ifdef CURL_DISABLE_PROXY
4281 data->set.proxy_ssl.primary.verifystatus;
4293 char *
p = (
char *)&conn->align_data__do_not_use;
4294 conn->
ssl[0].backend = (
struct ssl_backend_data *)
p;
4295 conn->
ssl[1].backend =
4304 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
4305 defined(NTLM_WB_ENABLED)
4307 conn->ntlm_auth_hlpr_pid = 0;
4308 conn->challenge_header = NULL;
4309 conn->response_header = NULL;
4325 conn->data_prot = PROT_CLEAR;
4356 const char *protostr)
4364 for(pp =
protocols; (
p = *pp) != NULL; pp++) {
4367 if(!(
data->set.allowed_protocols &
p->protocol))
4373 if(
data->state.this_is_a_follow &&
4374 !(
data->set.redir_protocols &
p->protocol))
4402 char **userp,
char **passwdp,
4411 const char *protop =
"";
4413 bool rebuild_url =
FALSE;
4414 bool url_has_scheme =
FALSE;
4417 *prot_missing =
FALSE;
4421 if(strpbrk(
data->change.url,
"\r\n")) {
4422 failf(
data,
"Illegal characters found in URL");
4434 if(
data->change.url[0] ==
':') {
4435 failf(
data,
"Bad URL, colon is first character");
4440 #define STARTS_WITH_DRIVE_PREFIX(str) \
4441 ((('a' <= str[0] && str[0] <= 'z') || \
4442 ('A' <= str[0] && str[0] <= 'Z')) && \
4453 for(
i = 0;
i < 16 &&
data->change.url[
i]; ++
i) {
4454 if(
data->change.url[
i] ==
'/')
4456 if(
data->change.url[
i] ==
':') {
4457 url_has_scheme =
TRUE;
4468 rc = sscanf(
data->change.url,
"%*15[^\n/:]:%[^\n]",
path);
4470 rc = sscanf(
data->change.url,
"%[^\n]",
path);
4477 if(url_has_scheme &&
path[0] ==
'/' &&
path[1] ==
'/') {
4499 failf(
data,
"Invalid file://hostname/, "
4500 "expected localhost or 127.0.0.1 or none");
4529 #if !defined(MSDOS) && !defined(WIN32) && !defined(__CYGWIN__)
4531 failf(
data,
"File drive letters are only accepted in MSDOS/Windows.");
4537 *prot_missing = !url_has_scheme;
4544 rc = sscanf(
data->change.url,
4545 "%15[^\n/:]:%3[/]%[^\n/?#]%[^\n]",
4564 #if defined(__DJGPP__) && (DJGPP_MINOR == 4)
4600 *prot_missing =
TRUE;
4603 size_t s = strlen(slashbuf);
4606 infof(
data,
"Unwillingly accepted illegal URL using %d slash%s!\n",
4609 if(
data->change.url_alloc)
4614 if(!
data->change.url)
4627 query = strchr(at + 1,
'?');
4629 query = strchr(conn->
host.
name,
'?');
4640 size_t hostlen = strlen(query);
4641 size_t pathlen = strlen(
path);
4645 memmove(
path + hostlen + 1,
path, pathlen + 1);
4665 if(
path[0] !=
'/') {
4673 else if(!
data->set.path_as_is) {
4679 if(strcmp(newp,
path)) {
4682 data->state.pathbuffer = newp;
4683 data->state.path = newp;
4699 size_t plen = strlen(
path);
4701 size_t prefixlen = strlen(conn->
host.
name);
4703 if(!*prot_missing) {
4704 size_t protolen = strlen(protop);
4707 prefixlen += protolen;
4717 prefixlen += 1 + (
data->change.url[5] ==
'/');
4724 reurl =
malloc(prefixlen + plen + 1);
4735 if(
data->change.url_alloc) {
4740 infof(
data,
"Rebuilt URL to: %s\n", reurl);
4742 data->change.url = reurl;
4761 char *percent = strchr(conn->
host.
name,
'%');
4763 unsigned int identifier_offset = 3;
4765 unsigned long scope;
4766 if(strncmp(
"%25", percent, 3) != 0) {
4768 "Please URL encode %% as %%25, see RFC 6874.\n");
4769 identifier_offset = 1;
4771 scope = strtoul(percent + identifier_offset, &endp, 10);
4775 memmove(percent, endp, strlen(endp) + 1);
4776 conn->
scope_id = (
unsigned int)scope;
4780 #if defined(HAVE_NET_IF_H) && defined(IFNAMSIZ) && defined(HAVE_IF_NAMETOINDEX)
4781 char ifname[IFNAMSIZ + 2];
4782 char *square_bracket;
4783 unsigned int scopeidx = 0;
4784 strncpy(ifname, percent + identifier_offset, IFNAMSIZ + 2);
4786 ifname[IFNAMSIZ + 1] =
'\0';
4787 square_bracket = strchr(ifname,
']');
4788 if(square_bracket) {
4790 *square_bracket =
'\0';
4791 scopeidx = if_nametoindex(ifname);
4793 infof(
data,
"Invalid network interface: %s; %s\n", ifname,
4798 char *
p = percent + identifier_offset + strlen(ifname);
4801 memmove(percent,
p, strlen(
p) + 1);
4806 infof(
data,
"Invalid IPv6 address format\n");
4811 if(
data->set.scope_id)
4818 fragment = strchr(
path,
'#');
4825 fragment = strchr(
data->change.url,
'#');
4846 s->resume_from =
data->set.set_resume_from;
4848 if(
s->rangestringalloc)
4862 s->use_range =
TRUE;
4894 data->req.maxdownload = -1;
4901 if(
p->setup_connection) {
4902 result = (*
p->setup_connection)(conn);
4913 conn->
port =
p->defport;
4930 #ifndef CURL_DISABLE_PROXY
4944 const char *separator =
", ";
4945 size_t no_proxy_len;
4949 if(no_proxy && no_proxy[0]) {
4956 no_proxy_len = strlen(no_proxy);
4957 endptr = strchr(
name,
':');
4959 namelen = endptr -
name;
4961 namelen = strlen(
name);
4963 for(tok_start = 0; tok_start < no_proxy_len; tok_start = tok_end + 1) {
4964 while(tok_start < no_proxy_len &&
4965 strchr(separator, no_proxy[tok_start]) != NULL) {
4970 if(tok_start == no_proxy_len)
4973 for(tok_end = tok_start; tok_end < no_proxy_len &&
4974 strchr(separator, no_proxy[tok_end]) == NULL; ++tok_end)
4982 if(no_proxy[tok_start] ==
'.')
4985 if((tok_end - tok_start) <= namelen) {
4987 const char *checkn =
name + namelen - (tok_end - tok_start);
4989 tok_end - tok_start)) {
4990 if((tok_end - tok_start) == namelen || *(checkn - 1) ==
'.') {
5005 #ifndef CURL_DISABLE_HTTP
5032 char proxy_env[128];
5034 char *envp = proxy_env;
5039 *envp++ = (char)tolower((
int)*protop++);
5042 strcpy(envp,
"_proxy");
5094 char *proxyuser = NULL;
5095 char *proxypasswd = NULL;
5103 endofprot = strstr(proxy,
"://");
5105 proxyptr = endofprot + 3;
5120 failf(
data,
"Unsupported proxy scheme for \'%s\'", proxy);
5131 failf(
data,
"Unsupported proxy \'%s\', libcurl is built without the "
5132 "HTTPS-proxy support.", proxy);
5142 atsign = strchr(proxyptr,
'@');
5146 &proxyuser, &proxypasswd, NULL);
5149 proxyptr = atsign + 1;
5156 if(*proxyptr ==
'[') {
5157 char *
ptr = ++proxyptr;
5162 if(strncmp(
"%25",
ptr, 3))
5163 infof(
data,
"Please URL encode %% as %%25, see RFC 6874.\n");
5167 (*
ptr ==
'.') || (*
ptr ==
'_') || (*
ptr ==
'~')))
5174 infof(
data,
"Invalid IPv6 address format\n");
5183 prox_portno = strchr(portptr,
':');
5190 port = strtol(prox_portno, &endp, 10);
5191 if((endp && *endp && (*endp !=
'/') && (*endp !=
' ')) ||
5198 infof(
data,
"No valid port number in proxy string (%s)\n",
5205 if(proxyptr[0]==
'/') {
5216 atsign = strchr(proxyptr,
'/');
5220 if(
data->set.proxyport)
5245 if(!proxyinfo->
user) {
5318 char *socksproxy = NULL;
5319 char *no_proxy = NULL;
5348 if(NULL == socksproxy) {
5366 #ifndef CURL_DISABLE_HTTP
5367 else if(!proxy && !socksproxy)
5374 #ifdef USE_UNIX_SOCKETS
5376 if(proxy && conn->unix_domain_socket) {
5387 if(socksproxy && (!*socksproxy ||
5399 if(proxy || socksproxy) {
5417 #ifdef CURL_DISABLE_HTTP
5496 char **user,
char **passwd,
char **
options)
5500 char *passwdp = NULL;
5501 char *optionsp = NULL;
5570 *passwd = newpasswd;
5625 char **userp,
char **passwdp,
5632 const char *psep = NULL;
5633 const char *osep = NULL;
5640 psep = strchr(
login,
':');
5649 osep = strchr(
login,
';');
5661 (osep && osep > psep ? (
size_t)(osep - psep) :
5664 (psep && psep > osep ? (
size_t)(psep - osep) :
5675 if(!
result && passwdp && plen) {
5684 if(!
result && optionsp && olen) {
5704 memcpy(pbuf, psep + 1, plen);
5712 memcpy(obuf, osep + 1, olen);
5745 if((1 == sscanf(conn->
host.
name,
"[%*45[0123456789abcdefABCDEF:.]%c",
5747 (
']' == endbracket)) {
5752 portptr = strchr(conn->
host.
name,
']');
5761 struct in6_addr in6;
5765 failf(
data,
"IPv6 numerical address used in URL without brackets");
5770 portptr = strchr(conn->
host.
name,
':');
5773 if(
data->set.use_port &&
data->state.allow_port) {
5785 snprintf(type,
sizeof(type),
";type=%c",
5786 data->set.prefer_ascii?
'A':
5787 (
data->set.ftp_list_only?
'D':
'I'));
5797 data->state.slash_removed?
"/":
"",
data->state.path,
5802 if(
data->change.url_alloc) {
5807 data->change.url = url;
5817 port = strtol(portptr + 1, &rest, 10);
5819 if((
port < 0) || (
port > 0xffff)) {
5821 failf(
data,
"Port number out of range");
5826 failf(
data,
"Port number ended with '%c'", rest[0]);
5830 if(rest != &portptr[1]) {
5856 char **userp,
char **passwdp,
char **optionsp)
5885 infof(
data,
"Couldn't find host %s in the "
5886 DOT_CHAR "netrc file; using defaults\n",
5909 const char *user,
const char *passwd,
5959 char **hostname_result,
5968 #if defined(CURL_DISABLE_VERBOSE_STRINGS)
5972 *hostname_result = NULL;
5988 if(*hostptr ==
'[') {
5989 char *
ptr = ++hostptr;
5994 if(strncmp(
"%25",
ptr, 3))
5995 infof(
data,
"Please URL encode %% as %%25, see RFC 6874.\n");
5999 (*
ptr ==
'.') || (*
ptr ==
'_') || (*
ptr ==
'~')))
6006 infof(
data,
"Invalid IPv6 address format\n");
6015 host_portno = strchr(portptr,
':');
6018 *host_portno =
'\0';
6021 long portparse = strtol(host_portno, &endp, 10);
6022 if((endp && *endp) || (portparse < 0) || (portparse > 65535)) {
6023 infof(
data,
"No valid port number in connect to host string (%s)\n",
6029 port = (int)portparse;
6035 *hostname_result =
strdup(hostptr);
6036 if(!*hostname_result) {
6042 *port_result =
port;
6054 const char *conn_to_host,
6059 const char *
ptr = conn_to_host;
6060 int host_match =
FALSE;
6061 int port_match =
FALSE;
6063 *host_result = NULL;
6073 size_t hostname_to_match_len;
6074 char *hostname_to_match =
aprintf(
"%s%s%s",
6078 if(!hostname_to_match)
6080 hostname_to_match_len = strlen(hostname_to_match);
6082 hostname_to_match_len);
6083 free(hostname_to_match);
6084 ptr += hostname_to_match_len;
6086 host_match = host_match && *
ptr ==
':';
6098 char *ptr_next = strchr(
ptr,
':');
6101 long port_to_match = strtol(
ptr, &endp, 10);
6102 if((endp == ptr_next) && (port_to_match == conn->
remote_port)) {
6110 if(host_match && port_match) {
6130 while(conn_to_host && !host &&
port == -1) {
6141 infof(
data,
"Connecting to hostname: %s\n", host);
6160 conn_to_host = conn_to_host->
next;
6190 #ifdef USE_UNIX_SOCKETS
6191 if(conn->unix_domain_socket) {
6195 const char *
path = conn->unix_domain_socket;
6201 bool longpath =
FALSE;
6202 hostaddr->
addr = Curl_unix2addr(
path, &longpath,
6203 conn->abstract_unix_socket);
6226 connhost = &conn->
host;
6237 &hostaddr, timeout_ms);
6244 else if(!hostaddr) {
6258 &hostaddr, timeout_ms);
6266 else if(!hostaddr) {
6309 old_conn->
user = NULL;
6362 #ifdef USE_UNIX_SOCKETS
6395 bool prot_missing =
FALSE;
6396 bool connections_available =
TRUE;
6397 bool force_reuse =
FALSE;
6398 bool waitpipe =
FALSE;
6408 if(!
data->change.url) {
6437 #define LEAST_PATH_ALLOC 256
6438 urllen = strlen(
data->change.url);
6449 data->state.path = NULL;
6452 if(NULL ==
data->state.pathbuffer) {
6456 data->state.path =
data->state.pathbuffer;
6461 data->state.path = NULL;
6500 for(ch_lower = reurl; *ch_lower !=
':'; ch_lower++)
6501 *ch_lower = (
char)
TOLOWER(*ch_lower);
6503 if(
data->change.url_alloc) {
6508 data->change.url = reurl;
6538 #ifdef USE_UNIX_SOCKETS
6539 if(
data->set.str[STRING_UNIX_SOCKET_PATH]) {
6540 conn->unix_domain_socket =
strdup(
data->set.str[STRING_UNIX_SOCKET_PATH]);
6541 if(conn->unix_domain_socket == NULL) {
6545 conn->abstract_unix_socket =
data->set.abstract_unix_socket;
6551 #ifndef CURL_DISABLE_PROXY
6642 #ifndef CURL_DISABLE_FILE
6693 data->set.proxy_ssl.primary.random_file =
6697 data->set.ssl.primary.cipher_list =
6699 data->set.proxy_ssl.primary.cipher_list =
6719 data->set.ssl.username =
data->set.str[STRING_TLSAUTH_USERNAME_ORIG];
6720 data->set.proxy_ssl.username =
data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
6721 data->set.ssl.password =
data->set.str[STRING_TLSAUTH_PASSWORD_ORIG];
6722 data->set.proxy_ssl.password =
data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
6749 if(
data->set.reuse_fresh && !
data->state.this_is_a_follow)
6759 infof(
data,
"Found connection %ld, with requests in the pipe (%zu)\n",
6763 data->state.conn_cache->num_connections < max_total_connections) {
6767 infof(
data,
"We can reuse, but we want a new connection anyway\n");
6786 infof(
data,
"Re-using existing connection! (#%ld) with %s %s\n",
6802 if(
data->set.ssl_enable_alpn)
6804 if(
data->set.ssl_enable_npn)
6811 connections_available =
FALSE;
6815 if(max_host_connections > 0 && bundle &&
6822 if(conn_candidate) {
6828 infof(
data,
"No more connections allowed to host: %d\n",
6829 max_host_connections);
6830 connections_available =
FALSE;
6834 if(connections_available &&
6835 (max_total_connections > 0) &&
6836 (
data->state.conn_cache->num_connections >= max_total_connections)) {
6842 if(conn_candidate) {
6848 infof(
data,
"No connections available in cache\n");
6849 connections_available =
FALSE;
6853 if(!connections_available) {
6854 infof(
data,
"No connections available.\n");
6870 #if defined(USE_NTLM)
6875 data->state.authhost.done) {
6876 infof(
data,
"NTLM picked AND auth done set, clear picked!\n");
6882 data->state.authproxy.done) {
6883 infof(
data,
"NTLM-proxy picked AND auth done set, clear picked!\n");
6934 bool *protocol_done)
6943 *protocol_done =
TRUE;
6946 *protocol_done =
FALSE;
6967 data->req.headerbytecount = 0;
6969 #ifdef CURL_DO_LINEEND_CONV
6970 data->state.crlf_conversions = 0;
6987 *protocol_done =
TRUE;
7003 if((
data->set.out)->_handle == NULL) {
7004 _fsetmode(stdout,
"b");
7014 bool *protocol_done)
7025 if((*in_connect)->send_pipe.size || (*in_connect)->recv_pipe.size)
7027 *protocol_done =
TRUE;
7041 if(
result && *in_connect) {
7072 if(
data->set.opt_no_body)
7115 unsigned int family;