logo

ap-client

Unnamed repository; edit this file 'description' to name the repository.
commit: a493d11d503afe1a5bd81f902dfdbf91ed0b3ee6
parent: b77528ed7f76611ffc8ef115d53f05b54040edba
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  5 May 2020 23:36:50 +0200

ap-fetch.sh: new file

Diffstat:

Aap-fetch.sh21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/ap-fetch.sh b/ap-fetch.sh @@ -0,0 +1,21 @@ +#!/bin/sh +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 + +curl -sSL -H "${accept_header}" -I $@ | tee /dev/stderr | grep -q -i -e '^Content-Type: application/.*json' + +if [[ "$?" != 0 ]] +then + die "Doesn’t have “Content-Type: application/.*json” in the headers" +fi + +curl -sSL -H "${accept_header}" $@