cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Fake-referer and remote file-exist check & size-check usinglibcurl?...

From: Fernando Cassia <fcassia_at_compuserve.com>
Date: Thu, 27 Feb 2003 12:17:35 -0300

Thanks Daniel!

And how do I do a http-get request with a fake referer and custom user-agent?
Care to post an example?

Regards
Fernando

Daniel Stenberg wrote:

>
> On Thu, 27 Feb 2003, Fernando Cassia wrote:
>
> > 1) Can I use libcurl to replace the "file_size" function and query the
> > remote file size?. how?
>
> (Please note that I'm not a PHP-dude, I'm talking from a general libcurl
> perspective here.)
>
> Yes, probably. If you use a HEAD request to the site with the JPEG, it'll
> return headers containing the size of the object.
>
> You make a HEAD request by using the CURLOPT_NOBODY option.
>
> > 2) How can I check if the remote file I'm querying exists (is a jpeg) or
> > instead the remote web server forwards me to the providers' 404 page?
>
> Sure. If you attempt to get it, you'll get a set of headers and a 404 code
> back if it doesn't exist. I'm not sure how much the PHP binding reflects
> this, but using the curl_easy_getinfo() you can get the HTTP code from the
> last request, or you can possibly use the CURLOPT_FAILONERROR option. Or
> simply parse the returned headers yourself.
>
> > 3) Anyone cares to post a "fake-referer" http-get, first checking if the
> > file exists and its size?
>
> Steps:
>
> 1. Set CURLOPT_REFERER to a suitable URL
> 2. do a HEAD
> 3. If the code is not 404, check the size
> 4. get the image.
>
> Not that I understand why you need to get the size first. You'll figure out
> how big the image is when you get it! ;-)
>
> --
> Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-02-27