Lines Matching +full:persist +full:- +full:credentials

8  * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
94 #include "non-ascii.h"
97 #include "urlapi-int.h"
149 * 'h' [in] - struct Curl_handler pointer.
156 DEBUGASSERT(h->family); in get_protocol_family()
157 return h->family; in get_protocol_family()
299 /* Free all dynamic strings stored in the data->set substructure. */ in Curl_freeset()
304 Curl_safefree(data->set.str[i]); in Curl_freeset()
308 Curl_safefree(data->set.blobs[j]); in Curl_freeset()
311 if(data->change.referer_alloc) { in Curl_freeset()
312 Curl_safefree(data->change.referer); in Curl_freeset()
313 data->change.referer_alloc = FALSE; in Curl_freeset()
315 data->change.referer = NULL; in Curl_freeset()
316 if(data->change.url_alloc) { in Curl_freeset()
317 Curl_safefree(data->change.url); in Curl_freeset()
318 data->change.url_alloc = FALSE; in Curl_freeset()
320 data->change.url = NULL; in Curl_freeset()
322 Curl_mime_cleanpart(&data->set.mimepost); in Curl_freeset()
328 struct urlpieces *up = &data->state.up; in up_free()
329 Curl_safefree(up->scheme); in up_free()
330 Curl_safefree(up->hostname); in up_free()
331 Curl_safefree(up->port); in up_free()
332 Curl_safefree(up->user); in up_free()
333 Curl_safefree(up->password); in up_free()
334 Curl_safefree(up->options); in up_free()
335 Curl_safefree(up->path); in up_free()
336 Curl_safefree(up->query); in up_free()
337 curl_url_cleanup(data->state.uh); in up_free()
338 data->state.uh = NULL; in up_free()
363 m = data->multi; in Curl_close()
367 curl_multi_remove_handle(data->multi, data); in Curl_close()
369 if(data->multi_easy) { in Curl_close()
372 curl_multi_cleanup(data->multi_easy); in Curl_close()
373 data->multi_easy = NULL; in Curl_close()
379 Curl_llist_destroy(&data->state.timeoutlist, NULL); in Curl_close()
381 data->magic = 0; /* force a clear AFTER the possibly enforced removal from in Curl_close()
385 if(data->state.rangestringalloc) in Curl_close()
386 free(data->state.range); in Curl_close()
393 Curl_safefree(data->state.first_host); in Curl_close()
394 Curl_safefree(data->state.scratch); in Curl_close()
398 free(data->req.newurl); in Curl_close()
399 data->req.newurl = NULL; in Curl_close()
401 if(data->change.referer_alloc) { in Curl_close()
402 Curl_safefree(data->change.referer); in Curl_close()
403 data->change.referer_alloc = FALSE; in Curl_close()
405 data->change.referer = NULL; in Curl_close()
408 Curl_safefree(data->state.buffer); in Curl_close()
409 Curl_dyn_free(&data->state.headerb); in Curl_close()
410 Curl_safefree(data->state.ulbuf); in Curl_close()
412 Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]); in Curl_close()
413 Curl_altsvc_cleanup(&data->asi); in Curl_close()
417 Curl_safefree(data->info.contenttype); in Curl_close()
418 Curl_safefree(data->info.wouldredirect); in Curl_close()
421 Curl_resolver_cleanup(data->state.resolver); in Curl_close()
427 if(data->share) { in Curl_close()
429 data->share->dirty--; in Curl_close()
433 Curl_safefree(data->state.aptr.proxyuserpwd); in Curl_close()
434 Curl_safefree(data->state.aptr.uagent); in Curl_close()
435 Curl_safefree(data->state.aptr.userpwd); in Curl_close()
436 Curl_safefree(data->state.aptr.accept_encoding); in Curl_close()
437 Curl_safefree(data->state.aptr.te); in Curl_close()
438 Curl_safefree(data->state.aptr.rangeline); in Curl_close()
439 Curl_safefree(data->state.aptr.ref); in Curl_close()
440 Curl_safefree(data->state.aptr.host); in Curl_close()
441 Curl_safefree(data->state.aptr.cookiehost); in Curl_close()
442 Curl_safefree(data->state.aptr.rtsp_transport); in Curl_close()
445 Curl_dyn_free(&data->req.doh.probe[0].serverdoh); in Curl_close()
446 Curl_dyn_free(&data->req.doh.probe[1].serverdoh); in Curl_close()
447 curl_slist_free_all(data->req.doh.headers); in Curl_close()
451 Curl_wildcard_dtor(&data->wildcard); in Curl_close()
463 struct UserDefined *set = &data->set; in Curl_init_userdefined()
466 set->out = stdout; /* default output to stdout */ in Curl_init_userdefined()
467 set->in_set = stdin; /* default input from stdin */ in Curl_init_userdefined()
468 set->err = stderr; /* default stderr to stderr */ in Curl_init_userdefined()
471 set->fwrite_func = (curl_write_callback)fwrite; in Curl_init_userdefined()
474 set->fread_func_set = (curl_read_callback)fread; in Curl_init_userdefined()
475 set->is_fread_set = 0; in Curl_init_userdefined()
476 set->is_fwrite_set = 0; in Curl_init_userdefined()
478 set->seek_func = ZERO_NULL; in Curl_init_userdefined()
479 set->seek_client = ZERO_NULL; in Curl_init_userdefined()
481 /* conversion callbacks for non-ASCII hosts */ in Curl_init_userdefined()
482 set->convfromnetwork = ZERO_NULL; in Curl_init_userdefined()
483 set->convtonetwork = ZERO_NULL; in Curl_init_userdefined()
484 set->convfromutf8 = ZERO_NULL; in Curl_init_userdefined()
486 set->filesize = -1; /* we don't know the size */ in Curl_init_userdefined()
487 set->postfieldsize = -1; /* unknown size */ in Curl_init_userdefined()
488 set->maxredirs = -1; /* allow any amount by default */ in Curl_init_userdefined()
490 set->method = HTTPREQ_GET; /* Default HTTP request */ in Curl_init_userdefined()
491 set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */ in Curl_init_userdefined()
493 set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */ in Curl_init_userdefined()
494 set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */ in Curl_init_userdefined()
495 set->ftp_use_pret = FALSE; /* mainly useful for drftpd servers */ in Curl_init_userdefined()
496 set->ftp_filemethod = FTPFILE_MULTICWD; in Curl_init_userdefined()
498 set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */ in Curl_init_userdefined()
501 set->general_ssl.max_ssl_sessions = 5; in Curl_init_userdefined()
503 set->proxyport = 0; in Curl_init_userdefined()
504 set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */ in Curl_init_userdefined()
505 set->httpauth = CURLAUTH_BASIC; /* defaults to basic */ in Curl_init_userdefined()
506 set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */ in Curl_init_userdefined()
508 /* SOCKS5 proxy auth defaults to username/password + GSS-API */ in Curl_init_userdefined()
509 set->socks5auth = CURLAUTH_BASIC | CURLAUTH_GSSAPI; in Curl_init_userdefined()
512 set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */ in Curl_init_userdefined()
514 Curl_mime_initpart(&set->mimepost, data); in Curl_init_userdefined()
520 set->ssl.primary.verifypeer = TRUE; in Curl_init_userdefined()
521 set->ssl.primary.verifyhost = TRUE; in Curl_init_userdefined()
523 set->ssl.authtype = CURL_TLSAUTH_NONE; in Curl_init_userdefined()
525 set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth in Curl_init_userdefined()
527 set->ssl.primary.sessionid = TRUE; /* session ID caching enabled by in Curl_init_userdefined()
530 set->proxy_ssl = set->ssl; in Curl_init_userdefined()
533 set->new_file_perms = 0644; /* Default permissions */ in Curl_init_userdefined()
534 set->new_directory_perms = 0755; /* Default permissions */ in Curl_init_userdefined()
539 set->allowed_protocols = CURLPROTO_ALL; in Curl_init_userdefined()
540 set->redir_protocols = CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | in Curl_init_userdefined()
548 set->socks5_gssapi_nec = FALSE; in Curl_init_userdefined()
555 * specified by the user via CURLOPT_CAINFO / --cacert. in Curl_init_userdefined()
559 result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE); in Curl_init_userdefined()
563 result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY], in Curl_init_userdefined()
569 result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], CURL_CA_PATH); in Curl_init_userdefined()
573 result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH); in Curl_init_userdefined()
579 set->wildcard_enabled = FALSE; in Curl_init_userdefined()
580 set->chunk_bgn = ZERO_NULL; in Curl_init_userdefined()
581 set->chunk_end = ZERO_NULL; in Curl_init_userdefined()
582 set->tcp_keepalive = FALSE; in Curl_init_userdefined()
583 set->tcp_keepintvl = 60; in Curl_init_userdefined()
584 set->tcp_keepidle = 60; in Curl_init_userdefined()
585 set->tcp_fastopen = FALSE; in Curl_init_userdefined()
586 set->tcp_nodelay = TRUE; in Curl_init_userdefined()
587 set->ssl_enable_npn = TRUE; in Curl_init_userdefined()
588 set->ssl_enable_alpn = TRUE; in Curl_init_userdefined()
589 set->expect_100_timeout = 1000L; /* Wait for a second by default. */ in Curl_init_userdefined()
590 set->sep_headers = TRUE; /* separated header lists by default */ in Curl_init_userdefined()
591 set->buffer_size = READBUFFER_SIZE; in Curl_init_userdefined()
592 set->upload_buffer_size = UPLOADBUFFER_DEFAULT; in Curl_init_userdefined()
593 set->happy_eyeballs_timeout = CURL_HET_DEFAULT; in Curl_init_userdefined()
594 set->fnmatch = ZERO_NULL; in Curl_init_userdefined()
595 set->upkeep_interval_ms = CURL_UPKEEP_INTERVAL_DEFAULT; in Curl_init_userdefined()
596 set->maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */ in Curl_init_userdefined()
597 set->maxage_conn = 118; in Curl_init_userdefined()
598 set->http09_allowed = FALSE; in Curl_init_userdefined()
599 set->httpversion = in Curl_init_userdefined()
623 /* Very simple start-up: alloc the struct, init it with zeroes and return */ in Curl_open()
631 data->magic = CURLEASY_MAGIC_NUMBER; in Curl_open()
633 result = Curl_resolver_init(data, &data->state.resolver); in Curl_open()
642 Curl_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER); in Curl_open()
647 data->state.lastconnect_id = -1; in Curl_open()
649 data->progress.flags |= PGRS_HIDE; in Curl_open()
650 data->state.current_speed = -1; /* init to negative == impossible */ in Curl_open()
654 Curl_resolver_cleanup(data->state.resolver); in Curl_open()
655 Curl_dyn_free(&data->state.headerb); in Curl_open()
669 struct postponed_data * const psnd = &(conn->postponed[num]); in conn_reset_postponed_data()
670 if(psnd->buffer) { in conn_reset_postponed_data()
671 DEBUGASSERT(psnd->allocated_size > 0); in conn_reset_postponed_data()
672 DEBUGASSERT(psnd->recv_size <= psnd->allocated_size); in conn_reset_postponed_data()
673 DEBUGASSERT(psnd->recv_size ? in conn_reset_postponed_data()
674 (psnd->recv_processed < psnd->recv_size) : in conn_reset_postponed_data()
675 (psnd->recv_processed == 0)); in conn_reset_postponed_data()
676 DEBUGASSERT(psnd->bindsock != CURL_SOCKET_BAD); in conn_reset_postponed_data()
677 free(psnd->buffer); in conn_reset_postponed_data()
678 psnd->buffer = NULL; in conn_reset_postponed_data()
679 psnd->allocated_size = 0; in conn_reset_postponed_data()
680 psnd->recv_size = 0; in conn_reset_postponed_data()
681 psnd->recv_processed = 0; in conn_reset_postponed_data()
683 psnd->bindsock = CURL_SOCKET_BAD; /* used only for DEBUGASSERT */ in conn_reset_postponed_data()
687 DEBUGASSERT(psnd->allocated_size == 0); in conn_reset_postponed_data()
688 DEBUGASSERT(psnd->recv_size == 0); in conn_reset_postponed_data()
689 DEBUGASSERT(psnd->recv_processed == 0); in conn_reset_postponed_data()
690 DEBUGASSERT(psnd->bindsock == CURL_SOCKET_BAD); in conn_reset_postponed_data()
700 /* Use "do-nothing" macro instead of function when workaround not used */
708 infof(conn->data, "Closing connection %ld\n", conn->connection_id); in conn_shutdown()
709 DEBUGASSERT(conn->data); in conn_shutdown()
711 /* possible left-overs from the async name resolvers */ in conn_shutdown()
720 if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) in conn_shutdown()
721 Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]); in conn_shutdown()
722 if(CURL_SOCKET_BAD != conn->sock[FIRSTSOCKET]) in conn_shutdown()
723 Curl_closesocket(conn, conn->sock[FIRSTSOCKET]); in conn_shutdown()
724 if(CURL_SOCKET_BAD != conn->tempsock[0]) in conn_shutdown()
725 Curl_closesocket(conn, conn->tempsock[0]); in conn_shutdown()
726 if(CURL_SOCKET_BAD != conn->tempsock[1]) in conn_shutdown()
727 Curl_closesocket(conn, conn->tempsock[1]); in conn_shutdown()
734 Curl_free_idnconverted_hostname(&conn->host); in conn_free()
735 Curl_free_idnconverted_hostname(&conn->conn_to_host); in conn_free()
737 Curl_free_idnconverted_hostname(&conn->http_proxy.host); in conn_free()
738 Curl_free_idnconverted_hostname(&conn->socks_proxy.host); in conn_free()
739 Curl_safefree(conn->http_proxy.user); in conn_free()
740 Curl_safefree(conn->socks_proxy.user); in conn_free()
741 Curl_safefree(conn->http_proxy.passwd); in conn_free()
742 Curl_safefree(conn->socks_proxy.passwd); in conn_free()
743 Curl_safefree(conn->http_proxy.host.rawalloc); /* http proxy name buffer */ in conn_free()
744 Curl_safefree(conn->socks_proxy.host.rawalloc); /* socks proxy name buffer */ in conn_free()
745 Curl_free_primary_ssl_config(&conn->proxy_ssl_config); in conn_free()
747 Curl_safefree(conn->user); in conn_free()
748 Curl_safefree(conn->passwd); in conn_free()
749 Curl_safefree(conn->sasl_authzid); in conn_free()
750 Curl_safefree(conn->options); in conn_free()
751 Curl_dyn_free(&conn->trailer); in conn_free()
752 Curl_safefree(conn->host.rawalloc); /* host name buffer */ in conn_free()
753 Curl_safefree(conn->conn_to_host.rawalloc); /* host name buffer */ in conn_free()
754 Curl_safefree(conn->hostname_resolve); in conn_free()
755 Curl_safefree(conn->secondaryhostname); in conn_free()
756 Curl_safefree(conn->connect_state); in conn_free()
759 Curl_llist_destroy(&conn->easyq, NULL); in conn_free()
760 Curl_safefree(conn->localdev); in conn_free()
761 Curl_free_primary_ssl_config(&conn->ssl_config); in conn_free()
764 Curl_safefree(conn->unix_domain_socket); in conn_free()
768 Curl_safefree(conn->ssl_extra); in conn_free()
783 * isn't strictly bound to the life-time of *this* particular connection.
794 DEBUGASSERT(!conn->bundle); in Curl_disconnect()
800 DEBUGASSERT(!data->conn); in Curl_disconnect()
803 * If this connection isn't marked to force-close, leave it open if there in Curl_disconnect()
811 if(conn->dns_entry != NULL) { in Curl_disconnect()
812 Curl_resolv_unlock(data, conn->dns_entry); in Curl_disconnect()
813 conn->dns_entry = NULL; in Curl_disconnect()
816 /* Cleanup NTLM connection-related data */ in Curl_disconnect()
819 /* Cleanup NEGOTIATE connection-related data */ in Curl_disconnect()
824 conn->data = data; in Curl_disconnect()
826 if(conn->bits.connect_only) in Curl_disconnect()
830 if(conn->handler->disconnect) in Curl_disconnect()
831 /* This is set if protocol-specific cleanups should be made */ in Curl_disconnect()
832 conn->handler->disconnect(conn, dead_connection); in Curl_disconnect()
869 if((conn->handler->protocol & PROTO_FAMILY_HTTP) && in IsMultiplexingPossible()
870 (!conn->bits.protoconnstart || !conn->bits.close)) { in IsMultiplexingPossible()
872 if(Curl_multiplex_wanted(handle->multi) && in IsMultiplexingPossible()
873 (handle->set.httpversion >= CURL_HTTP_VERSION_2)) in IsMultiplexingPossible()
885 if((data->proxytype == needle->proxytype) && in proxy_info_matches()
886 (data->port == needle->port) && in proxy_info_matches()
887 Curl_safe_strcasecompare(data->host.name, needle->host.name)) in proxy_info_matches()
900 /* the user information is case-sensitive in socks_proxy_info_matches()
901 or at least it is not defined as case-insensitive in socks_proxy_info_matches()
902 see https://tools.ietf.org/html/rfc3986#section-3.2.1 */ in socks_proxy_info_matches()
903 if((data->user == NULL) != (needle->user == NULL)) in socks_proxy_info_matches()
906 if(data->user && in socks_proxy_info_matches()
907 needle->user && in socks_proxy_info_matches()
908 strcmp(data->user, needle->user) != 0) in socks_proxy_info_matches()
910 if((data->passwd == NULL) != (needle->passwd == NULL)) in socks_proxy_info_matches()
913 if(data->passwd && in socks_proxy_info_matches()
914 needle->passwd && in socks_proxy_info_matches()
915 strcmp(data->passwd, needle->passwd) != 0) in socks_proxy_info_matches()
932 if(!conn->data) { in conn_maxage()
933 timediff_t idletime = Curl_timediff(now, conn->lastused); in conn_maxage()
936 if(idletime > data->set.maxage_conn) { in conn_maxage()
957 if(!CONN_INUSE(conn) && !conn->data) { in extract_if_dead()
965 else if(conn->handler->connection_check) { in extract_if_dead()
969 struct Curl_easy *olddata = conn->data; in extract_if_dead()
970 conn->data = data; /* use this transfer for now */ in extract_if_dead()
971 state = conn->handler->connection_check(conn, CONNCHECK_ISDEAD); in extract_if_dead()
972 conn->data = olddata; in extract_if_dead()
977 dead = SocketIsDead(conn->sock[FIRSTSOCKET]); in extract_if_dead()
981 infof(data, "Connection %ld seems to be dead!\n", conn->connection_id); in extract_if_dead()
1001 if(extract_if_dead(conn, p->data)) { in call_extract_if_dead()
1003 p->extracted = conn; in call_extract_if_dead()
1010 * This function scans the connection cache for half-open/dead connections,
1021 Curl_timediff(now, data->state.conn_cache->last_cleanup); in prune_dead_connections()
1028 while(Curl_conncache_foreach(data, data->state.conn_cache, &prune, in prune_dead_connections()
1039 data->state.conn_cache->last_cleanup = now; in prune_dead_connections()
1049 * If there is a match, this function returns TRUE - and has marked the
1050 * connection as 'in-use'. It must later be called with ConnectionDone() to
1070 bool wantNTLMhttp = ((data->state.authhost.want & in ConnectionExists()
1072 (needle->handler->protocol & PROTO_FAMILY_HTTP)); in ConnectionExists()
1074 bool wantProxyNTLMhttp = (needle->bits.proxy_user_passwd && in ConnectionExists()
1075 ((data->state.authproxy.want & in ConnectionExists()
1077 (needle->handler->protocol & PROTO_FAMILY_HTTP))); in ConnectionExists()
1088 bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache, in ConnectionExists()
1095 hostbundle, (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ? in ConnectionExists()
1100 if(bundle->multiuse == BUNDLE_UNKNOWN) { in ConnectionExists()
1101 if(data->set.pipewait) { in ConnectionExists()
1105 return FALSE; /* no re-use */ in ConnectionExists()
1111 if((bundle->multiuse == BUNDLE_MULTIPLEX) && in ConnectionExists()
1112 !Curl_multiplex_wanted(data->multi)) { in ConnectionExists()
1116 if(bundle->multiuse == BUNDLE_NO_MULTIUSE) { in ConnectionExists()
1122 curr = bundle->conn_list.head; in ConnectionExists()
1131 check = curr->ptr; in ConnectionExists()
1132 curr = curr->next; in ConnectionExists()
1134 if(check->bits.connect_only || check->bits.close) in ConnectionExists()
1135 /* connect-only or to-be-closed connections will not be reused */ in ConnectionExists()
1144 if(bundle->multiuse == BUNDLE_MULTIPLEX) in ConnectionExists()
1159 completed yet and until then we don't re-use this connection */ in ConnectionExists()
1160 if(!check->ip_addr_str[0]) { in ConnectionExists()
1163 check->connection_id); in ConnectionExists()
1168 if(check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) { in ConnectionExists()
1172 check->connection_id); in ConnectionExists()
1178 if(needle->unix_domain_socket) { in ConnectionExists()
1179 if(!check->unix_domain_socket) in ConnectionExists()
1181 if(strcmp(needle->unix_domain_socket, check->unix_domain_socket)) in ConnectionExists()
1183 if(needle->bits.abstract_unix_socket != in ConnectionExists()
1184 check->bits.abstract_unix_socket) in ConnectionExists()
1187 else if(check->unix_domain_socket) in ConnectionExists()
1191 if((needle->handler->flags&PROTOPT_SSL) != in ConnectionExists()
1192 (check->handler->flags&PROTOPT_SSL)) in ConnectionExists()
1193 /* don't do mixed SSL and non-SSL connections */ in ConnectionExists()
1194 if(get_protocol_family(check->handler) != in ConnectionExists()
1195 needle->handler->protocol || !check->bits.tls_upgraded) in ConnectionExists()
1200 if(needle->bits.httpproxy != check->bits.httpproxy || in ConnectionExists()
1201 needle->bits.socksproxy != check->bits.socksproxy) in ConnectionExists()
1204 if(needle->bits.socksproxy && in ConnectionExists()
1205 !socks_proxy_info_matches(&needle->socks_proxy, in ConnectionExists()
1206 &check->socks_proxy)) in ConnectionExists()
1209 if(needle->bits.conn_to_host != check->bits.conn_to_host) in ConnectionExists()
1214 if(needle->bits.conn_to_port != check->bits.conn_to_port) in ConnectionExists()
1220 if(needle->bits.httpproxy) { in ConnectionExists()
1221 if(!proxy_info_matches(&needle->http_proxy, &check->http_proxy)) in ConnectionExists()
1224 if(needle->bits.tunnel_proxy != check->bits.tunnel_proxy) in ConnectionExists()
1227 if(needle->http_proxy.proxytype == CURLPROXY_HTTPS) { in ConnectionExists()
1229 if(needle->handler->flags&PROTOPT_SSL) { in ConnectionExists()
1231 if(!Curl_ssl_config_matches(&needle->proxy_ssl_config, in ConnectionExists()
1232 &check->proxy_ssl_config)) in ConnectionExists()
1234 if(check->proxy_ssl[FIRSTSOCKET].state != ssl_connection_complete) in ConnectionExists()
1238 if(!Curl_ssl_config_matches(&needle->ssl_config, in ConnectionExists()
1239 &check->ssl_config)) in ConnectionExists()
1241 if(check->ssl[FIRSTSOCKET].state != ssl_connection_complete) in ConnectionExists()
1248 DEBUGASSERT(!check->data || GOOD_EASY_HANDLE(check->data)); in ConnectionExists()
1250 if(!canmultiplex && check->data) in ConnectionExists()
1255 if(check->data && (check->data->multi != needle->data->multi)) in ConnectionExists()
1260 if(needle->localdev || needle->localport) { in ConnectionExists()
1262 re-use a random other one, although if we didn't ask for a in ConnectionExists()
1268 Instead, this matching will assume that re-uses of bound connections in ConnectionExists()
1269 will most likely also re-use the exact same binding parameters and in ConnectionExists()
1272 if((check->localport != needle->localport) || in ConnectionExists()
1273 (check->localportrange != needle->localportrange) || in ConnectionExists()
1274 (needle->localdev && in ConnectionExists()
1275 (!check->localdev || strcmp(check->localdev, needle->localdev)))) in ConnectionExists()
1279 if(!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) { in ConnectionExists()
1280 /* This protocol requires credentials per connection, in ConnectionExists()
1282 if(strcmp(needle->user, check->user) || in ConnectionExists()
1283 strcmp(needle->passwd, check->passwd)) { in ConnectionExists()
1289 if((needle->handler->flags&PROTOPT_SSL) in ConnectionExists()
1291 || !needle->bits.httpproxy || needle->bits.tunnel_proxy in ConnectionExists()
1295 it is a non-SSL protocol tunneled or it is a non-SSL protocol which in ConnectionExists()
1298 if((strcasecompare(needle->handler->scheme, check->handler->scheme) || in ConnectionExists()
1299 (get_protocol_family(check->handler) == in ConnectionExists()
1300 needle->handler->protocol && check->bits.tls_upgraded)) && in ConnectionExists()
1301 (!needle->bits.conn_to_host || strcasecompare( in ConnectionExists()
1302 needle->conn_to_host.name, check->conn_to_host.name)) && in ConnectionExists()
1303 (!needle->bits.conn_to_port || in ConnectionExists()
1304 needle->conn_to_port == check->conn_to_port) && in ConnectionExists()
1305 strcasecompare(needle->host.name, check->host.name) && in ConnectionExists()
1306 needle->remote_port == check->remote_port) { in ConnectionExists()
1310 if(needle->handler->flags & PROTOPT_SSL) { in ConnectionExists()
1313 if(!Curl_ssl_config_matches(&needle->ssl_config, in ConnectionExists()
1314 &check->ssl_config)) { in ConnectionExists()
1318 check->connection_id)); in ConnectionExists()
1321 if(check->ssl[FIRSTSOCKET].state != ssl_connection_complete) { in ConnectionExists()
1326 check->connection_id)); in ConnectionExists()
1342 already authenticating with the right credentials. If not, keep in ConnectionExists()
1347 if(strcmp(needle->user, check->user) || in ConnectionExists()
1348 strcmp(needle->passwd, check->passwd)) { in ConnectionExists()
1352 if(check->http_ntlm_state == NTLMSTATE_NONE) in ConnectionExists()
1357 else if(check->http_ntlm_state != NTLMSTATE_NONE) { in ConnectionExists()
1365 /* Both check->http_proxy.user and check->http_proxy.passwd can be in ConnectionExists()
1367 if(!check->http_proxy.user || !check->http_proxy.passwd) in ConnectionExists()
1370 if(strcmp(needle->http_proxy.user, check->http_proxy.user) || in ConnectionExists()
1371 strcmp(needle->http_proxy.passwd, check->http_proxy.passwd)) in ConnectionExists()
1374 else if(check->proxy_ntlm_state != NTLMSTATE_NONE) { in ConnectionExists()
1380 /* Credentials are already checked, we can use this connection */ in ConnectionExists()
1384 (check->http_ntlm_state != NTLMSTATE_NONE)) || in ConnectionExists()
1386 (check->proxy_ntlm_state != NTLMSTATE_NONE))) { in ConnectionExists()
1408 if(check->bits.multiplex) { in ConnectionExists()
1410 struct http_conn *httpc = &check->proto.httpc; in ConnectionExists()
1411 if(multiplexed >= httpc->settings.max_concurrent_streams) { in ConnectionExists()
1417 Curl_multi_max_concurrent_streams(needle->data->multi)) { in ConnectionExists()
1441 chosen->data = data; /* own it! */ in ConnectionExists()
1449 if(foundPendingCandidate && data->set.pipewait) { in ConnectionExists()
1464 if(conn->data->set.verbose) in Curl_verboseconnect()
1465 infof(conn->data, "Connected to %s (%s) port %ld (#%ld)\n", in Curl_verboseconnect()
1467 conn->bits.socksproxy ? conn->socks_proxy.host.dispname : in Curl_verboseconnect()
1468 conn->bits.httpproxy ? conn->http_proxy.host.dispname : in Curl_verboseconnect()
1470 conn->bits.conn_to_host ? conn->conn_to_host.dispname : in Curl_verboseconnect()
1471 conn->host.dispname, in Curl_verboseconnect()
1472 conn->ip_addr_str, conn->port, conn->connection_id); in Curl_verboseconnect()
1501 if(!host || !host->name) in strip_trailing_dot()
1503 len = strlen(host->name); in strip_trailing_dot()
1504 if(len && (host->name[len-1] == '.')) in strip_trailing_dot()
1505 host->name[len-1] = 0; in strip_trailing_dot()
1514 struct Curl_easy *data = conn->data; in Curl_idnconvert_hostname()
1524 host->dispname = host->name; in Curl_idnconvert_hostname()
1526 /* Check name for non-ASCII and convert hostname to ACE form if we can */ in Curl_idnconvert_hostname()
1527 if(!Curl_is_ASCII_name(host->name)) { in Curl_idnconvert_hostname()
1533 IDN2_NONTRANSITIONAL: Perform Unicode TR46 non-transitional in Curl_idnconvert_hostname()
1539 int rc = idn2_lookup_ul((const char *)host->name, &ace_hostname, flags); in Curl_idnconvert_hostname()
1541 host->encalloc = (char *)ace_hostname; in Curl_idnconvert_hostname()
1543 host->name = host->encalloc; in Curl_idnconvert_hostname()
1546 failf(data, "Failed to convert %s to ACE; %s\n", host->name, in Curl_idnconvert_hostname()
1554 if(curl_win32_idn_to_ascii(host->name, &ace_hostname)) { in Curl_idnconvert_hostname()
1555 host->encalloc = ace_hostname; in Curl_idnconvert_hostname()
1557 host->name = host->encalloc; in Curl_idnconvert_hostname()
1561 failf(data, "Failed to convert %s to ACE; %s\n", host->name, in Curl_idnconvert_hostname()
1578 if(host->encalloc) { in Curl_free_idnconverted_hostname()
1579 idn2_free(host->encalloc); /* must be freed with idn2_free() since this was in Curl_free_idnconverted_hostname()
1581 host->encalloc = NULL; in Curl_free_idnconverted_hostname()
1584 free(host->encalloc); /* must be freed with free() since this was in Curl_free_idnconverted_hostname()
1586 host->encalloc = NULL; in Curl_free_idnconverted_hostname()
1602 /* The SSL backend-specific data (ssl_backend_data) objects are allocated as in allocate_conn()
1607 size_t sslsize = Curl_ssl->sizeof_ssl_backend_data; in allocate_conn()
1613 conn->ssl_extra = ssl; in allocate_conn()
1614 conn->ssl[0].backend = (void *)ssl; in allocate_conn()
1615 conn->ssl[1].backend = (void *)(ssl + sslsize); in allocate_conn()
1617 conn->proxy_ssl[0].backend = (void *)(ssl + 2 * sslsize); in allocate_conn()
1618 conn->proxy_ssl[1].backend = (void *)(ssl + 3 * sslsize); in allocate_conn()
1623 conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined in allocate_conn()
1629 conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1630 conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1631 conn->tempsock[0] = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1632 conn->tempsock[1] = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1633 conn->connection_id = -1; /* no ID */ in allocate_conn()
1634 conn->port = -1; /* unknown at this point */ in allocate_conn()
1635 conn->remote_port = -1; /* unknown at this point */ in allocate_conn()
1637 conn->postponed[0].bindsock = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1638 conn->postponed[1].bindsock = CURL_SOCKET_BAD; /* no file descriptor */ in allocate_conn()
1641 /* Default protocol-independent behavior doesn't support persistent in allocate_conn()
1642 connections, so we set this to force-close. Protocols that support in allocate_conn()
1644 connclose(conn, "Default to force-close"); in allocate_conn()
1647 conn->created = Curl_now(); in allocate_conn()
1650 conn->keepalive = Curl_now(); in allocate_conn()
1653 conn->upkeep_interval_ms = data->set.upkeep_interval_ms; in allocate_conn()
1655 conn->data = data; /* Setup the association between this connection in allocate_conn()
1659 conn->http_proxy.proxytype = data->set.proxytype; in allocate_conn()
1660 conn->socks_proxy.proxytype = CURLPROXY_SOCKS4; in allocate_conn()
1664 conn->bits.proxy = (data->set.str[STRING_PROXY] && in allocate_conn()
1665 *data->set.str[STRING_PROXY]) ? TRUE : FALSE; in allocate_conn()
1666 conn->bits.httpproxy = (conn->bits.proxy && in allocate_conn()
1667 (conn->http_proxy.proxytype == CURLPROXY_HTTP || in allocate_conn()
1668 conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0 || in allocate_conn()
1669 conn->http_proxy.proxytype == CURLPROXY_HTTPS)) ? in allocate_conn()
1671 conn->bits.socksproxy = (conn->bits.proxy && in allocate_conn()
1672 !conn->bits.httpproxy) ? TRUE : FALSE; in allocate_conn()
1674 if(data->set.str[STRING_PRE_PROXY] && *data->set.str[STRING_PRE_PROXY]) { in allocate_conn()
1675 conn->bits.proxy = TRUE; in allocate_conn()
1676 conn->bits.socksproxy = TRUE; in allocate_conn()
1679 conn->bits.proxy_user_passwd = in allocate_conn()
1680 (data->set.str[STRING_PROXYUSERNAME]) ? TRUE : FALSE; in allocate_conn()
1681 conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy; in allocate_conn()
1684 conn->bits.user_passwd = (data->set.str[STRING_USERNAME]) ? TRUE : FALSE; in allocate_conn()
1686 conn->bits.ftp_use_epsv = data->set.ftp_use_epsv; in allocate_conn()
1687 conn->bits.ftp_use_eprt = data->set.ftp_use_eprt; in allocate_conn()
1689 conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus; in allocate_conn()
1690 conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer; in allocate_conn()
1691 conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost; in allocate_conn()
1693 conn->proxy_ssl_config.verifystatus = in allocate_conn()
1694 data->set.proxy_ssl.primary.verifystatus; in allocate_conn()
1695 conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer; in allocate_conn()
1696 conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost; in allocate_conn()
1698 conn->ip_version = data->set.ipver; in allocate_conn()
1699 conn->bits.connect_only = data->set.connect_only; in allocate_conn()
1700 conn->transport = TRNSPRT_TCP; /* most of them are TCP streams */ in allocate_conn()
1704 conn->ntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD; in allocate_conn()
1705 conn->proxyntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD; in allocate_conn()
1709 Curl_llist_init(&conn->easyq, NULL); in allocate_conn()
1712 conn->data_prot = PROT_CLEAR; in allocate_conn()
1716 if(data->set.str[STRING_DEVICE]) { in allocate_conn()
1717 conn->localdev = strdup(data->set.str[STRING_DEVICE]); in allocate_conn()
1718 if(!conn->localdev) in allocate_conn()
1721 conn->localportrange = data->set.localportrange; in allocate_conn()
1722 conn->localport = data->set.localport; in allocate_conn()
1726 conn->fclosesocket = data->set.fclosesocket; in allocate_conn()
1727 conn->closesocket_client = data->set.closesocket_client; in allocate_conn()
1728 conn->lastused = Curl_now(); /* used now */ in allocate_conn()
1733 Curl_llist_destroy(&conn->easyq, NULL); in allocate_conn()
1734 free(conn->localdev); in allocate_conn()
1736 free(conn->ssl_extra); in allocate_conn()
1742 /* returns the handler if the given scheme is built-in */
1750 if(strcasecompare(p->scheme, scheme)) in Curl_builtin_scheme()
1764 (data->set.allowed_protocols & p->protocol)) { in findprotocol()
1768 if(data->state.this_is_a_follow && in findprotocol()
1769 !(data->set.redir_protocols & p->protocol)) in findprotocol()
1774 conn->handler = conn->given = p; in findprotocol()
1782 to anything since it is already assigned to a dummy-struct in the in findprotocol()
1822 conn->scope_id = (unsigned int)scope;
1838 infof(conn->data, "Invalid zoneid: %s; %s\n", zoneid,
1841 conn->scope_id = scopeidx;
1859 bool use_set_uh = (data->set.uh && !data->state.this_is_a_follow);
1865 uh = data->state.uh = curl_url_dup(data->set.uh);
1868 uh = data->state.uh = curl_url();
1874 if(data->set.str[STRING_DEFAULT_PROTOCOL] &&
1875 !Curl_is_absolute_url(data->change.url, NULL, MAX_SCHEME_LEN)) {
1877 if(data->change.url_alloc)
1878 free(data->change.url);
1879 url = aprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL],
1880 data->change.url);
1883 data->change.url = url;
1884 data->change.url_alloc = TRUE;
1889 uc = curl_url_set(uh, CURLUPART_URL, data->change.url,
1892 (data->set.disallow_username_in_url ?
1894 (data->set.path_as_is ? CURLU_PATH_AS_IS : 0));
1896 DEBUGF(infof(data, "curl_url_set rejected %s\n", data->change.url));
1904 if(data->change.url_alloc)
1905 free(data->change.url);
1906 data->change.url = newurl;
1907 data->change.url_alloc = TRUE;
1910 uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
1914 result = findprotocol(data, conn, data->state.up.scheme);
1921 uc = curl_url_get(uh, CURLUPART_USER, &data->state.up.user, 0);
1924 result = Curl_urldecode(NULL, data->state.up.user, 0, &decoded, NULL,
1925 conn->handler->flags&PROTOPT_USERPWDCTRL ?
1929 conn->user = decoded;
1930 conn->bits.user_passwd = TRUE;
1935 uc = curl_url_get(uh, CURLUPART_PASSWORD, &data->state.up.password, 0);
1938 result = Curl_urldecode(NULL, data->state.up.password, 0, &decoded, NULL,
1939 conn->handler->flags&PROTOPT_USERPWDCTRL ?
1943 conn->passwd = decoded;
1944 conn->bits.user_passwd = TRUE;
1949 uc = curl_url_get(uh, CURLUPART_OPTIONS, &data->state.up.options,
1952 conn->options = strdup(data->state.up.options);
1953 if(!conn->options)
1959 uc = curl_url_get(uh, CURLUPART_HOST, &data->state.up.hostname, 0);
1961 if(!strcasecompare("file", data->state.up.scheme))
1965 uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, 0);
1969 uc = curl_url_get(uh, CURLUPART_PORT, &data->state.up.port,
1972 if(!strcasecompare("file", data->state.up.scheme))
1976 unsigned long port = strtoul(data->state.up.port, NULL, 10);
1977 conn->port = conn->remote_port = curlx_ultous(port);
1980 (void)curl_url_get(uh, CURLUPART_QUERY, &data->state.up.query, 0);
1982 hostname = data->state.up.hostname;
1987 conn->bits.ipv6_ip = TRUE;
1991 hostname[hlen - 1] = 0;
1997 conn->host.rawalloc = strdup(hostname ? hostname : "");
1998 if(!conn->host.rawalloc)
2000 conn->host.name = conn->host.rawalloc;
2002 if(data->set.scope_id)
2004 conn->scope_id = data->set.scope_id;
2016 struct UrlState *s = &data->state;
2017 s->resume_from = data->set.set_resume_from;
2018 if(s->resume_from || data->set.str[STRING_SET_RANGE]) {
2019 if(s->rangestringalloc)
2020 free(s->range);
2022 if(s->resume_from)
2023 s->range = aprintf("%" CURL_FORMAT_CURL_OFF_T "-", s->resume_from);
2025 s->range = strdup(data->set.str[STRING_SET_RANGE]);
2027 s->rangestringalloc = (s->range) ? TRUE : FALSE;
2029 if(!s->range)
2033 s->use_range = TRUE; /* enable range download */
2036 s->use_range = FALSE; /* disable range download */
2043 * setup_connection_internals() -
2057 p = conn->handler;
2059 if(p->setup_connection) {
2060 result = (*p->setup_connection)(conn);
2065 p = conn->handler; /* May have changed. */
2068 if(conn->port < 0)
2069 /* we check for -1 here since if proxy was detected already, this
2071 conn->port = p->defport;
2083 Curl_safefree(data->req.protop);
2084 Curl_safefree(data->req.newurl);
2087 Curl_close(&data->req.doh.probe[0].easy);
2088 Curl_close(&data->req.doh.probe[1].easy);
2101 * (a comma-separated list of hosts which should
2125 namelen = endptr - name;
2152 if((tok_end - tok_start) <= namelen) {
2154 const char *checkn = name + namelen - (tok_end - tok_start);
2156 tok_end - tok_start)) {
2157 if((tok_end - tok_start) == namelen || *(checkn - 1) == '.') {
2164 } /* if((tok_end - tok_start) <= namelen) */
2189 * (a comma-separated list of hosts which should
2196 * For compatibility, the all-uppercase versions of these variables are
2200 const char *protop = conn->handler->scheme;
2245 infof(conn->data, "Uses proxy env variable %s == '%s'\n", envp, proxy);
2253 * host name, so that we can re-use an existing connection
2261 long port = -1;
2272 /* When parsing the proxy, allowing non-supported schemes since we have
2311 if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
2315 "HTTPS-proxy support.", proxy);
2326 proxyinfo = sockstype ? &conn->socks_proxy : &conn->http_proxy;
2327 proxyinfo->proxytype = proxytype;
2333 Curl_safefree(proxyinfo->user);
2334 proxyinfo->user = proxyuser;
2335 Curl_safefree(proxyinfo->passwd);
2343 proxyinfo->passwd = proxypasswd;
2344 conn->bits.proxy_user_passwd = TRUE; /* enable it */
2354 if(data->set.proxyport)
2357 port = data->set.proxyport;
2366 proxyinfo->port = port;
2367 if(conn->port < 0 || sockstype || !conn->socks_proxy.host.rawalloc)
2368 conn->port = port;
2377 Curl_safefree(proxyinfo->host.rawalloc);
2378 proxyinfo->host.rawalloc = host;
2382 host[len-1] = 0; /* clear the trailing bracket */
2386 proxyinfo->host.name = host;
2400 const char *proxyuser = data->set.str[STRING_PROXYUSERNAME] ?
2401 data->set.str[STRING_PROXYUSERNAME] : "";
2402 const char *proxypasswd = data->set.str[STRING_PROXYPASSWORD] ?
2403 data->set.str[STRING_PROXYPASSWORD] : "";
2407 result = Curl_urldecode(data, proxyuser, 0, &conn->http_proxy.user, NULL,
2410 result = Curl_urldecode(data, proxypasswd, 0, &conn->http_proxy.passwd,
2423 struct Curl_easy *data = conn->data;
2428 if(conn->bits.proxy_user_passwd) {
2437 if(data->set.str[STRING_PROXY]) {
2438 proxy = strdup(data->set.str[STRING_PROXY]);
2447 if(data->set.str[STRING_PRE_PROXY]) {
2448 socksproxy = strdup(data->set.str[STRING_PRE_PROXY]);
2457 if(!data->set.str[STRING_NOPROXY]) {
2465 infof(conn->data, "Uses proxy env variable %s == '%s'\n", p, no_proxy);
2469 if(check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY] ?
2470 data->set.str[STRING_NOPROXY] : no_proxy)) {
2484 if(proxy && conn->unix_domain_socket) {
2490 if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) {
2496 (conn->handler->flags & PROTOPT_NONETWORK))) {
2504 * name, proxy type and port number, so that we can re-use an existing
2509 result = parse_proxy(data, conn, proxy, conn->http_proxy.proxytype);
2517 conn->socks_proxy.proxytype);
2524 if(conn->http_proxy.host.rawalloc) {
2531 if(!(conn->handler->protocol & PROTO_FAMILY_HTTP)) {
2532 if((conn->handler->flags & PROTOPT_PROXY_AS_HTTP) &&
2533 !conn->bits.tunnel_proxy)
2534 conn->handler = &Curl_handler_http;
2537 conn->bits.tunnel_proxy = TRUE;
2539 conn->bits.httpproxy = TRUE;
2543 conn->bits.httpproxy = FALSE; /* not a HTTP proxy */
2544 conn->bits.tunnel_proxy = FALSE; /* no tunneling if not HTTP */
2547 if(conn->socks_proxy.host.rawalloc) {
2548 if(!conn->http_proxy.host.rawalloc) {
2550 if(!conn->socks_proxy.user) {
2551 conn->socks_proxy.user = conn->http_proxy.user;
2552 conn->http_proxy.user = NULL;
2553 Curl_safefree(conn->socks_proxy.passwd);
2554 conn->socks_proxy.passwd = conn->http_proxy.passwd;
2555 conn->http_proxy.passwd = NULL;
2558 conn->bits.socksproxy = TRUE;
2561 conn->bits.socksproxy = FALSE; /* not a socks proxy */
2564 conn->bits.socksproxy = FALSE;
2565 conn->bits.httpproxy = FALSE;
2567 conn->bits.proxy = conn->bits.httpproxy || conn->bits.socksproxy;
2569 if(!conn->bits.proxy) {
2571 conn->bits.proxy = FALSE;
2572 conn->bits.httpproxy = FALSE;
2573 conn->bits.socksproxy = FALSE;
2574 conn->bits.proxy_user_passwd = FALSE;
2575 conn->bits.tunnel_proxy = FALSE;
2576 /* CURLPROXY_HTTPS does not have its own flag in conn->bits, yet we need
2578 conn->http_proxy.proxytype = CURLPROXY_HTTP;
2607 * login [in] - The login string.
2608 * len [in] - The length of the login string.
2609 * userp [in/out] - The address where a pointer to newly allocated memory
2611 * passwdp [in/out] - The address where a pointer to newly allocated memory
2613 * optionsp [in/out] - The address where a pointer to newly allocated memory
2658 (size_t)(osep && psep > osep ? osep - login : psep - login) :
2659 (osep ? (size_t)(osep - login) : len));
2661 (osep && osep > psep ? (size_t)(osep - psep) :
2662 (size_t)(login + len - psep)) - 1 : 0);
2664 (psep && psep > osep ? (size_t)(psep - osep) :
2665 (size_t)(login + len - osep)) - 1 : 0);
2734 if(data->set.use_port && data->state.allow_port) {
2738 conn->remote_port = (unsigned short)data->set.use_port;
2739 msnprintf(portbuf, sizeof(portbuf), "%d", conn->remote_port);
2740 uc = curl_url_set(data->state.uh, CURLUPART_PORT, portbuf, 0);
2760 if(data->set.use_netrc == CURL_NETRC_REQUIRED && conn->bits.user_passwd) {
2770 conn->bits.user_passwd = FALSE; /* disable user+password */
2773 if(data->set.str[STRING_USERNAME]) {
2775 *userp = strdup(data->set.str[STRING_USERNAME]);
2778 conn->bits.user_passwd = TRUE; /* enable user+password */
2782 if(data->set.str[STRING_PASSWORD]) {
2784 *passwdp = strdup(data->set.str[STRING_PASSWORD]);
2787 conn->bits.user_passwd = TRUE; /* enable user+password */
2791 if(data->set.str[STRING_OPTIONS]) {
2793 *optionsp = strdup(data->set.str[STRING_OPTIONS]);
2798 conn->bits.netrc = FALSE;
2799 if(data->set.use_netrc != CURL_NETRC_IGNORED &&
2805 ret = Curl_parsenetrc(conn->host.name,
2808 data->set.str[STRING_NETRC_FILE]);
2811 conn->host.name);
2820 conn->bits.netrc = TRUE;
2821 conn->bits.user_passwd = TRUE; /* enable user+password */
2834 uc = curl_url_set(data->state.uh, CURLUPART_USER, *userp,
2840 uc = curl_url_set(data->state.uh, CURLUPART_PASSWORD, *passwdp,
2858 if((conn->handler->flags & PROTOPT_NEEDSPWD) && !conn->bits.user_passwd)
2865 if(!conn->user) {
2866 conn->user = strdup(setuser);
2867 if(!conn->user)
2872 if(!conn->passwd) {
2873 conn->passwd = strdup(setpasswd);
2874 if(!conn->passwd)
2884 * the hostname and -1 for the port.
2895 int port = -1;
2902 *port_result = -1;
2916 /* detect and extract RFC6874-style IPv6-addresses */
2928 while(*ptr && (ISALPHA(*ptr) || ISXDIGIT(*ptr) || (*ptr == '-') ||
2943 failf(data, "Use of IPv6 in *_CONNECT_TO without IPv6 support built-in!");
2961 port = -1;
2985 * "HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT".
2999 *port_result = -1;
3010 conn->bits.ipv6_ip ? "[" : "",
3011 conn->host.name,
3012 conn->bits.ipv6_ip ? "]" : "");
3037 if((endp == ptr_next) && (port_to_match == conn->remote_port)) {
3063 int port = -1;
3065 while(conn_to_host && !host && port == -1) {
3066 result = parse_connect_to_string(data, conn, conn_to_host->data,
3072 conn->conn_to_host.rawalloc = host;
3073 conn->conn_to_host.name = host;
3074 conn->bits.conn_to_host = TRUE;
3080 conn->bits.conn_to_host = FALSE;
3085 conn->conn_to_port = port;
3086 conn->bits.conn_to_port = TRUE;
3091 conn->bits.conn_to_port = FALSE;
3092 port = -1;
3095 conn_to_host = conn_to_host->next;
3099 if(data->asi && !host && (port == -1) &&
3100 ((conn->handler->protocol == CURLPROTO_HTTPS) ||
3108 /* no connect_to match, try alt-svc! */
3119 ) & data->asi->flags;
3121 host = conn->host.rawalloc;
3125 hit = Curl_altsvc_lookup(data->asi,
3126 srcalpnid, host, conn->remote_port, /* from */
3133 hit = Curl_altsvc_lookup(data->asi,
3134 srcalpnid, host, conn->remote_port, /* from */
3139 char *hostd = strdup((char *)as->dst.host);
3142 conn->conn_to_host.rawalloc = hostd;
3143 conn->conn_to_host.name = hostd;
3144 conn->bits.conn_to_host = TRUE;
3145 conn->conn_to_port = as->dst.port;
3146 conn->bits.conn_to_port = TRUE;
3147 conn->bits.altused = TRUE;
3148 infof(data, "Alt-svc connecting from [%s]%s:%d to [%s]%s:%d\n",
3149 Curl_alpnid2str(srcalpnid), host, conn->remote_port,
3150 Curl_alpnid2str(as->dst.alpnid), hostd, as->dst.port);
3151 if(srcalpnid != as->dst.alpnid) {
3153 switch(as->dst.alpnid) {
3155 conn->httpversion = 11;
3158 conn->httpversion = 20;
3161 conn->transport = TRNSPRT_QUIC;
3162 conn->httpversion = 30;
3190 if(conn->bits.reuse)
3191 /* We're reusing the connection - no need to resolve anything, and
3192 idnconvert_hostname() was called already in create_conn() for the re-use
3202 if(conn->unix_domain_socket) {
3206 const char *path = conn->unix_domain_socket;
3213 hostaddr->addr = Curl_unix2addr(path, &longpath,
3214 conn->bits.abstract_unix_socket);
3215 if(hostaddr->addr)
3216 hostaddr->inuse++;
3233 if(!conn->bits.proxy) {
3235 if(conn->bits.conn_to_host)
3236 connhost = &conn->conn_to_host;
3238 connhost = &conn->host;
3242 if(conn->bits.conn_to_port)
3243 conn->port = conn->conn_to_port;
3245 conn->port = conn->remote_port;
3248 conn->hostname_resolve = strdup(connhost->name);
3249 if(!conn->hostname_resolve)
3251 rc = Curl_resolv_timeout(conn, conn->hostname_resolve, (int)conn->port,
3260 failf(data, "Couldn't resolve host '%s'", connhost->dispname);
3269 struct hostname * const host = conn->bits.socksproxy ?
3270 &conn->socks_proxy.host : &conn->http_proxy.host;
3273 conn->hostname_resolve = strdup(host->name);
3274 if(!conn->hostname_resolve)
3276 rc = Curl_resolv_timeout(conn, conn->hostname_resolve, (int)conn->port,
3286 failf(data, "Couldn't resolve proxy '%s'", host->dispname);
3292 DEBUGASSERT(conn->dns_entry == NULL);
3293 conn->dns_entry = hostaddr;
3308 Curl_free_idnconverted_hostname(&old_conn->http_proxy.host);
3309 Curl_free_idnconverted_hostname(&old_conn->socks_proxy.host);
3311 free(old_conn->http_proxy.host.rawalloc);
3312 free(old_conn->socks_proxy.host.rawalloc);
3313 Curl_free_primary_ssl_config(&old_conn->proxy_ssl_config);
3317 Curl_free_primary_ssl_config(&old_conn->ssl_config);
3319 conn->data = old_conn->data;
3322 * be new for this request even when we re-use an existing connection */
3323 conn->bits.user_passwd = old_conn->bits.user_passwd;
3324 if(conn->bits.user_passwd) {
3326 Curl_safefree(conn->user);
3327 Curl_safefree(conn->passwd);
3328 conn->user = old_conn->user;
3329 conn->passwd = old_conn->passwd;
3330 old_conn->user = NULL;
3331 old_conn->passwd = NULL;
3335 conn->bits.proxy_user_passwd = old_conn->bits.proxy_user_passwd;
3336 if(conn->bits.proxy_user_passwd) {
3338 Curl_safefree(conn->http_proxy.user);
3339 Curl_safefree(conn->socks_proxy.user);
3340 Curl_safefree(conn->http_proxy.passwd);
3341 Curl_safefree(conn->socks_proxy.passwd);
3342 conn->http_proxy.user = old_conn->http_proxy.user;
3343 conn->socks_proxy.user = old_conn->socks_proxy.user;
3344 conn->http_proxy.passwd = old_conn->http_proxy.passwd;
3345 conn->socks_proxy.passwd = old_conn->socks_proxy.passwd;
3346 old_conn->http_proxy.user = NULL;
3347 old_conn->socks_proxy.user = NULL;
3348 old_conn->http_proxy.passwd = NULL;
3349 old_conn->socks_proxy.passwd = NULL;
3351 Curl_safefree(old_conn->http_proxy.user);
3352 Curl_safefree(old_conn->socks_proxy.user);
3353 Curl_safefree(old_conn->http_proxy.passwd);
3354 Curl_safefree(old_conn->socks_proxy.passwd);
3359 Curl_free_idnconverted_hostname(&conn->host);
3360 Curl_free_idnconverted_hostname(&conn->conn_to_host);
3361 Curl_safefree(conn->host.rawalloc);
3362 Curl_safefree(conn->conn_to_host.rawalloc);
3363 conn->host = old_conn->host;
3364 conn->conn_to_host = old_conn->conn_to_host;
3365 conn->conn_to_port = old_conn->conn_to_port;
3366 conn->remote_port = old_conn->remote_port;
3367 Curl_safefree(conn->hostname_resolve);
3369 conn->hostname_resolve = old_conn->hostname_resolve;
3370 old_conn->hostname_resolve = NULL;
3372 /* persist connection info in session handle */
3377 /* re-use init */
3378 conn->bits.reuse = TRUE; /* yes, we're re-using here */
3380 Curl_safefree(old_conn->user);
3381 Curl_safefree(old_conn->passwd);
3382 Curl_safefree(old_conn->options);
3383 Curl_safefree(old_conn->localdev);
3384 Curl_llist_destroy(&old_conn->easyq, NULL);
3387 Curl_safefree(old_conn->unix_domain_socket);
3392 * create_conn() sets up a new connectdata struct, or re-uses an already
3404 * *NOTE* this function assigns the conn->data pointer!
3418 size_t max_host_connections = Curl_multi_max_host_connections(data->multi);
3419 size_t max_total_connections = Curl_multi_max_total_connections(data->multi);
3427 if(!data->change.url) {
3452 if(data->set.str[STRING_SASL_AUTHZID]) {
3453 conn->sasl_authzid = strdup(data->set.str[STRING_SASL_AUTHZID]);
3454 if(!conn->sasl_authzid) {
3461 if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
3462 conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
3463 if(conn->unix_domain_socket == NULL) {
3467 conn->bits.abstract_unix_socket = data->set.abstract_unix_socket;
3482 if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy)
3483 conn->bits.tunnel_proxy = TRUE;
3494 they are known when protocol->setup_connection is called! */
3495 result = override_login(data, conn, &conn->user, &conn->passwd,
3496 &conn->options);
3500 result = set_login(conn); /* default credentials */
3508 result = parse_connect_to_slist(data, conn, data->set.connect_to);
3513 * IDN-convert the hostnames
3515 result = Curl_idnconvert_hostname(conn, &conn->host);
3518 if(conn->bits.conn_to_host) {
3519 result = Curl_idnconvert_hostname(conn, &conn->conn_to_host);
3524 if(conn->bits.httpproxy) {
3525 result = Curl_idnconvert_hostname(conn, &conn->http_proxy.host);
3529 if(conn->bits.socksproxy) {
3530 result = Curl_idnconvert_hostname(conn, &conn->socks_proxy.host);
3538 * Do this after the hostnames have been IDN-converted.
3540 if(conn->bits.conn_to_host &&
3541 strcasecompare(conn->conn_to_host.name, conn->host.name)) {
3542 conn->bits.conn_to_host = FALSE;
3549 if(conn->bits.conn_to_port && conn->conn_to_port == conn->remote_port) {
3550 conn->bits.conn_to_port = FALSE;
3558 if((conn->bits.conn_to_host || conn->bits.conn_to_port) &&
3559 conn->bits.httpproxy)
3560 conn->bits.tunnel_proxy = TRUE;
3571 conn->recv[FIRSTSOCKET] = Curl_recv_plain;
3572 conn->send[FIRSTSOCKET] = Curl_send_plain;
3573 conn->recv[SECONDARYSOCKET] = Curl_recv_plain;
3574 conn->send[SECONDARYSOCKET] = Curl_send_plain;
3576 conn->bits.tcp_fastopen = data->set.tcp_fastopen;
3582 if(conn->handler->flags & PROTOPT_NONETWORK) {
3586 DEBUGASSERT(conn->handler->connect_it);
3588 result = conn->handler->connect_it(conn, &done);
3592 conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
3595 result = Curl_conncache_add_conn(data->state.conn_cache, conn);
3604 DEBUGASSERT(conn->handler->done);
3605 /* we ignore the return code for the protocol-specific DONE */
3606 (void)conn->handler->done(conn, result, FALSE);
3609 Curl_setup_transfer(data, -1, -1, FALSE, -1);
3628 data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_ORIG];
3629 data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG];
3630 data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE];
3631 data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
3632 data->set.ssl.primary.cipher_list =
3633 data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
3634 data->set.ssl.primary.cipher_list13 =
3635 data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
3636 data->set.ssl.primary.pinned_key =
3637 data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
3638 data->set.ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_ORIG];
3639 data->set.ssl.primary.curves = data->set.str[STRING_SSL_EC_CURVES];
3642 data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
3643 data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY];
3644 data->set.proxy_ssl.primary.random_file =
3645 data->set.str[STRING_SSL_RANDOM_FILE];
3646 data->set.proxy_ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
3647 data->set.proxy_ssl.primary.cipher_list =
3648 data->set.str[STRING_SSL_CIPHER_LIST_PROXY];
3649 data->set.proxy_ssl.primary.cipher_list13 =
3650 data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
3651 data->set.proxy_ssl.primary.pinned_key =
3652 data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY];
3653 data->set.proxy_ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_PROXY];
3654 data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
3655 data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
3656 data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
3657 data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
3658 data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
3659 data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
3660 data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
3661 data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY];
3663 data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG];
3664 data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_ORIG];
3665 data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE_ORIG];
3666 data->set.ssl.key = data->set.str[STRING_KEY_ORIG];
3667 data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE_ORIG];
3668 data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_ORIG];
3669 data->set.ssl.primary.clientcert = data->set.str[STRING_CERT_ORIG];
3671 data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_ORIG];
3672 data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG];
3674 data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
3675 data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
3679 data->set.ssl.key_blob = data->set.blobs[BLOB_KEY_ORIG];
3680 data->set.ssl.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_ORIG];
3682 if(!Curl_clone_primary_ssl_config(&data->set.ssl.primary,
3683 &conn->ssl_config)) {
3689 if(!Curl_clone_primary_ssl_config(&data->set.proxy_ssl.primary,
3690 &conn->proxy_ssl_config)) {
3700 * re-use an already existing one or if we have to create a
3704 DEBUGASSERT(conn->user);
3705 DEBUGASSERT(conn->passwd);
3708 we only acknowledge this option if this is not a re-used connection
3709 already (which happens due to follow-location or during a HTTP
3711 if((data->set.reuse_fresh && !data->state.this_is_a_follow) ||
3712 data->set.connect_only)
3726 free(conn->ssl_extra);
3733 infof(data, "Re-using existing connection! (#%ld) with %s %s\n",
3734 conn->connection_id,
3735 conn->bits.proxy?"proxy":"host",
3736 conn->socks_proxy.host.name ? conn->socks_proxy.host.dispname :
3737 conn->http_proxy.host.name ? conn->http_proxy.host.dispname :
3738 conn->host.dispname);
3740 infof(data, "Re-using existing connection! (#%ld) with host %s\n",
3741 conn->connection_id, conn->host.dispname);
3749 if(conn->handler->flags & PROTOPT_ALPN_NPN) {
3752 if(data->set.ssl_enable_alpn)
3753 conn->bits.tls_enable_alpn = TRUE;
3754 if(data->set.ssl_enable_npn)
3755 conn->bits.tls_enable_npn = TRUE;
3766 Curl_conncache_find_bundle(conn, data->state.conn_cache, &bundlehost);
3769 (bundle->num_connections >= max_host_connections)) {
3820 result = Curl_conncache_add_conn(data->state.conn_cache, conn);
3829 if((data->state.authhost.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&
3830 data->state.authhost.done) {
3832 data->state.authhost.picked = CURLAUTH_NONE;
3833 data->state.authhost.done = FALSE;
3836 if((data->state.authproxy.picked & (CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&
3837 data->state.authproxy.done) {
3838 infof(data, "NTLM-proxy picked AND auth done set, clear picked!\n");
3839 data->state.authproxy.picked = CURLAUTH_NONE;
3840 data->state.authproxy.done = FALSE;
3861 conn->seek_func = data->set.seek_func;
3862 conn->seek_client = data->set.seek_client;
3870 strip_trailing_dot(&conn->host);
3872 if(conn->bits.httpproxy)
3873 strip_trailing_dot(&conn->http_proxy.host);
3874 if(conn->bits.socksproxy)
3875 strip_trailing_dot(&conn->socks_proxy.host);
3877 if(conn->bits.conn_to_host)
3878 strip_trailing_dot(&conn->conn_to_host);
3889 * conn->data MUST already have been setup fine (in create_conn)
3896 struct Curl_easy *data = conn->data;
3900 if(conn->handler->flags & PROTOPT_NONETWORK) {
3912 conn->bits.proxy_connect_closed = FALSE;
3915 * Set user-agent. Used for HTTP, but since we can attempt to tunnel
3919 if(data->set.str[STRING_USERAGENT]) {
3920 Curl_safefree(data->state.aptr.uagent);
3921 data->state.aptr.uagent =
3922 aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
3923 if(!data->state.aptr.uagent)
3927 data->req.headerbytecount = 0;
3930 data->state.crlf_conversions = 0; /* reset CRLF conversion counter */
3935 conn->now = Curl_now();
3937 if(CURL_SOCKET_BAD == conn->sock[FIRSTSOCKET]) {
3938 conn->bits.tcpconnect[FIRSTSOCKET] = FALSE;
3939 result = Curl_connecthost(conn, conn->dns_entry);
3945 if(conn->ssl[FIRSTSOCKET].use ||
3946 (conn->handler->protocol & PROTO_FAMILY_SSH))
3948 conn->bits.tcpconnect[FIRSTSOCKET] = TRUE;
3950 Curl_updateconninfo(conn, conn->sock[FIRSTSOCKET]);
3954 conn->now = Curl_now(); /* time this *after* the connect is done, we set
3968 /* init the single-transfer specific data */
3970 memset(&data->req, 0, sizeof(struct SingleRequest));
3971 data->req.maxdownload = -1;
4004 * the DO function before the protocol-specific DO functions are invoked) for
4014 struct SingleRequest *k = &data->req;
4022 conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
4025 if(data->state.wildcardmatch &&
4026 !(conn->handler->flags & PROTOPT_WILDCARD))
4027 data->state.wildcardmatch = FALSE;
4030 data->state.done = FALSE; /* *_done() is not called yet */
4031 data->state.expect100header = FALSE;
4033 if(data->set.opt_no_body)
4035 data->state.httpreq = HTTPREQ_HEAD;
4037 k->start = Curl_now(); /* start time */
4038 k->now = k->start; /* current time is now */
4039 k->header = TRUE; /* assume header */
4040 k->bytecount = 0;
4041 k->ignorebody = FALSE;