aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-11-04 14:58:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-11-04 14:58:15 +0100
commitafecd1aa13b4f40c54d195514af113715b0e0f9f (patch)
treebb4eb1046b55f2da4fc97531c17b12cd83d162c6 /lib/http.c
parent68cde058f66b3c3470f7e7d7068e40b236af6889 (diff)
host: get the custom Host: name more genericly
When given a custom host name in a Host: header, we can use it for several different purposes other than just cookies, so we rename it and use it for SSL SNI etc.
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/http.c b/lib/http.c
index ed0730c0a..0804ce050 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -2254,26 +2254,25 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
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;
}
@@ -2597,8 +2596,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
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);
@@ -3689,8 +3688,8 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
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);
}