cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Asynch DNS

From: <crpalmer_at_vivisimo.com>
Date: Tue, 18 Mar 2003 06:40:17 -0500

> > > 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.

On Tue, Mar 18, 2003 at 10:47:20AM +0100, Daniel Stenberg wrote:
> 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.

Yes, I recognize that this is in a slightly strange area of semantics.
I actually think it's pretty hard to justify one behaviour over another.
Having a follow location request discard the user specified host field
definitely seems like a deviation from the normal curl way of doing
things.

However, I'm hard pressed to think of any examples where you want
to both follow a redirection and preserve the host header. Can you?

And, as I said in my original email, if you don't think that this
is a bug, it would probably be a good idea to document the behaviour.
It's close enough to "working" that it's potentially surprising.

Cheers,
Chris.

-- 
Christopher R. Palmer                     palmer_at_vivisimo.com
Chief Technology Officer                  www.vivisimo.com
Vivisimo, Inc.                            412-422-2499
-------------------------------------------------------
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