I use curl to get http headers to find http status code and also return response. I get the http headers with the command
curl -I http://localhost
I was able to get a solution by looking at the curl doc which specifies to use - for the output to get the output to stdout.
-
curl -o - http://localhost
To get the response with just the http return code, I could just do
curl -o /dev/null -s -w "%{http_code}\n" http://localhost