Skip to content

Instantly share code, notes, and snippets.

@christopher-hopper
Last active July 9, 2024 01:03
Show Gist options
  • Save christopher-hopper/4a9694ba1c1f4692cacd849a9bd1cae1 to your computer and use it in GitHub Desktop.
Save christopher-hopper/4a9694ba1c1f4692cacd849a9bd1cae1 to your computer and use it in GitHub Desktop.
Testing HTTP response headers using wget or curl
# HTTP response header testing.
# wget
# - method: GET
# - output: response headers only
wget --server-response --quiet \
--output-document=/dev/null --output-file=- \
https://example.com/api/endpoint
# curl
# - method: GET
# - output: response headers only
curl --insecure --head --location --silent \
https://example.com/api/endpoint
# curl
# - short non-posix options
# - output: response headers only
#
# -k insecure, ignore cert problems
# -I headers only
# -L follow location redirects
# -s silent, no progress
curl -kILs https://example.com/api/endpoint
@christopher-hopper
Copy link
Author

Add a user-agent string to bypass some WAF (Web Application Firewall) checks that only allow requests from a real browser.

curl -kILs \
  --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36" \ 
  https://example.com/api/endpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment