curl-library
Re: Getting multiple Host: headers
Date: Thu, 22 Jul 2004 12:11:07 -0400
$ /usr/bin/curl-config --version
libcurl 7.12.0
I need to be able to override the Host header, because this is a "proxy"
type program. The hostname the user requests needs to be passed along.
Here's a dump of the tcp packets:
T 10.188.51.43:33531 -> 10.165.7.16:80 [AP]
GET /euro?this=that HTTP/1.1..Host: cnnsquid6..Pragma:
no-cache..Accept: */*..Host: bakinsu:9090..User-Agent: curl/7.12.
0 (i386-pc-linux-gnu) libcurl/7.12.0 OpenSSL/0.9.7d ipv6
zlib/1.2.1.1....
#
Notice, two Host Headers.
Sometime later, I get:
T 10.188.51.43:33537 -> 10.165.7.16:80 [AP]
GET /euro?this=that HTTP/1.1..Pragma: no-cache..Accept: */*..Host:
bakinsu:9090..User-Agent: curl/7.12.0 (i386-pc-linux-
gnu) libcurl/7.12.0 OpenSSL/0.9.7d ipv6
zlib/1.2.1.1....
##
Notice, now only one host header....
In the code, I do somthing like:
curl_easy_setopt(curl_handle, CURLOPT_URL,
"http://cnnsquid6/euro?this=that");
<>
and then something like:
curl_list = curl_slist_append(curl_list, "Host: bakinsu:9090);
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, curl_list);
>With 7.12.0 this seems to be working fine. Is there any particular
>reason why you want to overwrite the Host header?
>Regards
>-Seshubabu Pasam
>M. Brian Akins wrote:
/> I have basically this: /
/> /
/> curl_list = curl_slist_append(curl_list, value); /
/> /
/> where value is something like: "Host: bakinsu" /
/> /
/> and then, /
/> curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, curl_list); /
/> /
/> Using debug functions, this is what I am seeing (watch for wrap): /
/> /
/> GET /world HTTP/1.1\r\nHost: cnnsquid6\r\nPragma: no-cache\r\nAccept: /
/> */*\r\nUser-Agent: curl/7.11.2 (i386-pc-linux-gnu) libcurl/7.11.2 /
/> OpenSSL/0.9.7d ipv6 zlib/1.2.1.1\r\nHost: bakinsu\r\n\r\n /
/> /
/> I now have two Host: headers. What is strange is that occasionally it
works /
/> as I would expect it /
/> /
-- Brian Akins Senior Systems Engineer CNN Internet TechnologiesReceived on 2004-07-22