Skip to content

Instantly share code, notes, and snippets.

@kevinkarwaski
Created March 3, 2015 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinkarwaski/1e91b76fa19451be67f8 to your computer and use it in GitHub Desktop.
Save kevinkarwaski/1e91b76fa19451be67f8 to your computer and use it in GitHub Desktop.
Curl response headers helper
#!/usr/bin/env bash
# Return only response headers from Curl.
#
# Usage: curlHeaders http://www.someaddress.com
curl -k -s -D - $1 -o /dev/null
@ChrisRut
Copy link

Suggestion:

curl -fksD - -o /dev/null "$1"

I placed the options before the URL, added -f to cause curl to return a non-0 exitcode for non-200 responses and quoted the variable $1 to prevent globbing, ref: https://github.com/koalaman/shellcheck/wiki/SC2086

@ChrisRut
Copy link

also keep in mind -k should be used sparingly because you are blindly ignoring invalid certs

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