logo

ap-client

CLI-based client / toolbox for ActivityPub Client-to-Servergit clone https://hacktivis.me/git/ap-client.git

ap-fetch.sh (604B)


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