1

I'm using curl in PHP to check the HTTP code when requesting some files, I'm trying to make my speed run faster so I'm wondering is there a way to make it get the HTTP code without actually getting the web page from the remote host

hakre
  • 193,403
  • 52
  • 435
  • 836
Hintswen
  • 3,987
  • 12
  • 40
  • 45

1 Answers1

7

Set CURLOPT_NOBODY to true. This means that rather than preforming a GET or POST request, a HEAD request will be preformed so the remote server will only return the HTTP header.

curl_setopt($ch, CURLOPT_NOBODY, true);

There is also some example code in this answer

Community
  • 1
  • 1
Yacoby
  • 54,544
  • 15
  • 116
  • 120
  • Thanks for that. I was sure I've done it before but I just couldn't find it! Got my script down from 20 seconds to 7 seconds. – Hintswen Apr 15 '10 at 11:14