cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Retrieving specific header elements

From: Jason Thomas <jason_at_topic.com.au>
Date: Fri, 8 Feb 2002 08:54:43 +1100

On Thu, Feb 07, 2002 at 01:21:45PM +0100, Daniel Stenberg wrote:
> On Thu, 7 Feb 2002, Jason Thomas wrote:
>
> > Hi, I'm trying to use libcurl through php, and I'd like to be able to
> > extract the 'Location:' element from the header, do I need to parse the
> > headers myself or is there a way to get this from libcurl.
>
> I don't know how, or if, this is implemented in the PHP binding, but the
> general libcurl approach is to set a header callback. Then you'll get all
> headers passed to your function and then you can figure out whatever you want
> to figure out! ;-)

thats what I'm doing for the moment telling curl to dump the headers and
parsing them in my php code.

>
> > Looking at the code it seems that the headers are parsed but not stored,
>
> The necessary ones are stored all right, but not for easy retrieval by anyone
> afterwards.
>
> > maybe all the various header elements could be stored in a struct for use
> > with say 'writeout'.

so would it be of benefit if you could use 'writeout' to get a
particular header element?

--write-out header-location
--write-out header-set-cookie

each of these headers could be stored in a struct if found.

then I could access them from php

>
> With the command line client, you get all headers directed to a special file
> with the -D option.
>
> BTW, I hope that you've noticed that libcurl can be made to follow Location:
> headers automaticly if told so.

yep, but I have to send the cookie I got with the redirect. which curl
doesn't seem todo.
Received on 2002-02-07