ptr = Curl_checkheaders(data, "Host:");
if(ptr && (!data->state.this_is_a_follow ||
Curl_raw_equal(data->state.first_host, conn->host.name))) {
-#if !defined(CURL_DISABLE_COOKIES)
+
/* If we have a given custom Host: header, we extract the host name in
order to possibly use it for cookie reasons later on. We only allow the
custom Host: header if this is NOT a redirect, as setting Host: in the
redirected request is being out on thin ice. Except if the host name
is the same as the first one! */
- char *cookiehost = Curl_copy_header_value(ptr);
- if (!cookiehost)
+ char *chost = Curl_copy_header_value(ptr);
+ if (!chost)
return CURLE_OUT_OF_MEMORY;
- if (!*cookiehost)
+ if (!*chost)
/* ignore empty data */
- free(cookiehost);
+ free(chost);
else {
- char *colon = strchr(cookiehost, ':');
+ char *colon = strchr(chost, ':');
if (colon)
*colon = 0; /* The host must not include an embedded port number */
- Curl_safefree(conn->allocptr.cookiehost);
- conn->allocptr.cookiehost = cookiehost;
+ Curl_safefree(conn->allocptr.customhost);
+ conn->allocptr.customhost = chost;
}
-#endif
conn->allocptr.host = NULL;
}
if(data->cookies) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
co = Curl_cookie_getlist(data->cookies,
- conn->allocptr.cookiehost?
- conn->allocptr.cookiehost:host,
+ conn->allocptr.customhost?
+ conn->allocptr.customhost:host,
data->state.path,
(bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE));
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
data->cookies, TRUE, k->p+11,
/* If there is a custom-set Host: name, use it
here, or else use real peer host name. */
- conn->allocptr.cookiehost?
- conn->allocptr.cookiehost:conn->host.name,
+ conn->allocptr.customhost?
+ conn->allocptr.customhost:conn->host.name,
data->state.path);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
const char *hostname;
- bool hostname_static;
bool sni;
#ifdef ENABLE_IPV6
struct in6_addr addr;
connssl->server_cert = 0x0;
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
- hostname = Curl_checkheaders(data, "Host:");
- if(hostname && (!data->state.this_is_a_follow ||
- Curl_raw_equal(data->state.first_host, conn->host.name))) {
- hostname_static = FALSE;
- hostname = Curl_copy_header_value(hostname);
- if(!hostname) {
- return CURLE_OUT_OF_MEMORY;
- }
- } else {
- hostname_static = TRUE;
+ if((!data->state.this_is_a_follow ||
+ Curl_raw_equal(data->state.first_host, conn->host.name)) &&
+ conn->allocptr.customhost)
+ hostname = conn->allocptr.customhost;
+ else
hostname = conn->host.name;
- }
+
if ((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr)) &&
!SSL_set_tlsext_host_name(connssl->handle, hostname))
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
- if(!hostname_static)
- free((char *) hostname);
#endif
/* Check if there's a cached ID we can/should use here! */
Curl_safefree(conn->allocptr.rangeline);
Curl_safefree(conn->allocptr.ref);
Curl_safefree(conn->allocptr.host);
- Curl_safefree(conn->allocptr.cookiehost);
+ Curl_safefree(conn->allocptr.customhost);
Curl_safefree(conn->allocptr.rtsp_transport);
Curl_safefree(conn->trailer);
Curl_safefree(conn->host.rawalloc); /* host name buffer */