ap-fetch.sh (454B)
1 #!/bin/sh 2 url="$1" 3 accept_header='Accept: application/ld+json,application/activity+json,application/json' 4 5 die() { 6 echo $@ 7 exit 1 8 } 9 10 if [[ -z "${url}" ]] 11 then 12 die "Usage: ${0} [url]" 13 fi 14 15 curl -sSL -H "${accept_header}" ${url} -I | tee /dev/stderr | grep -q -i -e '^Content-Type: application/.*json' 16 17 if [[ "$?" != 0 ]] 18 then 19 die "Doesn’t have “Content-Type: application/.*json” in the headers" 20 fi 21 22 curl -sSL -H "${accept_header}" ${url} | jq .