Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created February 12, 2019 00:36
Show Gist options
  • Save mttjohnson/949565ee5152861b7f740b6882297798 to your computer and use it in GitHub Desktop.
Save mttjohnson/949565ee5152861b7f740b6882297798 to your computer and use it in GitHub Desktop.
Curl Testing Web Servers
# Curl manual: https://curl.haxx.se/docs/manpage.html
URL="https://www.example.org/"
HTTP_AUTH="-u name:passwd"
CURL_OPT="--trace -"
CURL_OUT="-o /dev/null"
curl -s ${HTTP_AUTH} ${CURL_OPT} ${CURL_OUT} -w "%{http_code} - ${URL}\n" "${URL}"
URL="https://www.example.org/"; HTTP_AUTH=""; CURL_OPT=""; CURL_OUT="-o /dev/null"; \
curl -s ${HTTP_AUTH} ${CURL_OPT} ${CURL_OUT} -w "%{http_code} - ${URL}\n" "${URL}"
# Override DNS and specify a different IP to connect to
URL="https://www.example.org/"
CURL_OPT="--resolve www.example.org:443:127.0.0.1"
CURL_OUT="-o /dev/null"
HTTP_AUTH=""
curl -s ${HTTP_AUTH} ${CURL_OPT} ${CURL_OUT} -w "%{http_code} - ${URL}\n" "${URL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment