cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Asynch DNS

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 18 Mar 2003 10:47:20 +0100 (CET)

On Mon, 17 Mar 2003 crpalmer_at_vivisimo.com wrote:

> > Nope. But you need to make sure to pass in a Host: header that is fine in
> > case you intend to play HTTP.
>
> The only catch with this plan is that you cannot then allow FOLLOWLOCATION.
> For example, http://cnn.com/ is redirected to http://www.cnn.com/. If I
> do:
>
> curl --location --max-redirs 2 -D - --header 'Host: cnn.com' 'http://64.236.24.4/'
>
> It will redirect itself continually (until the max is reached, of course),
> because the new request will be identical: the same IP and the same host
> field. This is with 7.10.3 on a redhat 7.2 linux box. I would have
> expected (or at least I hoped) that the location would override the host
> header field, instead of preserving it.
>
> Is this a bug? It seems like buggy behaviour to me, but it could also be
> the intended behaviour. If you don't think it's a bug, it might be a good
> idea to add a note or two to the documentation saying that adding Host
> header fields and using FOLLOWLOCATION are potentially incompatible.

Hm, this is a subject of discussion.

The reason for the never-ending loop is of course that since you've set the
"Host:" header in the list of custom-header-to-use, libcurl will use those
headers in all requests. That of course has its drawbacks when you follow a
location and you've passed in a Host: as it effectively disables the ability
to following locations to virtual-named hosts like the CNN example provided
above.

I personally don't think if this as a bug. "Fixing" this would take more
obscure options and weird things. I think that if you deal with Host: header
manipulations, you might as well deal with this too. Be it that you probably
end up having to do the follow-location code yourself to be able to provide
the correct Host: headers in all requests.

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink? 
You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
Received on 2003-03-18