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
This command
curl http://localhost -w ", %{http_code}"
will get the comma separated body and status; you can split them to get them out.
You can change the delimiter as you like.