This should work for you if the web server is able to respond to HEAD requests (this will not perform a GET
):
curl -I http://www.example.org
As an addition, to let cURL follow redirects (3xx statuses) add -L.
You are including invalid HTTP headers in your request:
$header[ ] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[ ] = "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
On the first line, the list ends with a ,
– that is, an empty content type – which is the cause of 406 Not acceptable errors. The second line is not even a HTTP header.
If you were looking at Firefox HTTP conversations with a packet sniffer, you probably saw something like this:
Accept: text/xml,application/xml,application/xhtml+xml,
text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Since the second line starts with whitespace, they are treated as a single header by the server. They must also be passed as one header to curl:
$header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
You can use http://echo.opera.com to compare the requests being sent.
Best Answer
curl --fail
does part of what you want:from
man curl
:But it blocks output to the screen.