Steve
Steve

Reputation: 3046

curl request header info and not the contents of the page

I'm writing a script that will use cURL to check a number of links. I know I can use curl_getinfo() to get the http status code, but I'm not sure if that requests the entire page or just the response with the headers. Is there any curl option or setting I can use to only request the headers of the URL (i.e. 404 not found, moved, etc) ?

Upvotes: 0

Views: 87

Answers (1)

Emanuil Rusev
Emanuil Rusev

Reputation: 35235

You can instruct cURL to not download the contents (body) of the request by setting the CURLOPT_NOBODY option to TRUE - see Does CURLOPT_NOBODY still download the body - using bandwidth

p.s. curl_getinfo() does not make requests - it gets information from requests that have already been executed.

Upvotes: 1

Related Questions