cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Retrieving specific header elements

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 7 Feb 2002 13:21:45 +0100 (MET)

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! ;-)

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

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.

Good luck!

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-02-07