ap-fetch.sh (604B)
- #!/bin/sh
- # AP-Client: CLI-based client / toolbox for ActivityPub
- # Copyright © 2020 AP-Client Authors <https://hacktivis.me/git/ap-client/>
- # SPDX-License-Identifier: BSD-3-Clause
- accept_header='Accept: application/ld+json,application/activity+json,application/json'
- die() {
- echo $@ >&2
- exit 1
- }
- if [ -z "$@" ]
- then
- die "Usage: ${0} [curl options] <url>"
- fi
- if curl -sSL -H "${accept_header}" -I $@ | tee /dev/stderr | grep -q -i -e '^Content-Type: application/.*json'
- then
- curl -sSL -H "${accept_header}" $@
- else
- die "Doesn’t have “Content-Type: application/.*json” in the headers"
- fi