# HG changeset patch # User Kim Alvefur # Date 1696171188 -7200 # Node ID e5ad3f1f48bd9d1a49e784ae5358d4a82d55f93d # Parent bbde136a4c29c957ec61139865d2a11997efe6d4 mod_rest/rest.sh: Restore default read-only behavior and the -rw flag diff -r bbde136a4c29 -r e5ad3f1f48bd mod_rest/example/rest.sh --- a/mod_rest/example/rest.sh Thu Sep 28 16:38:29 2023 +0200 +++ b/mod_rest/example/rest.sh Sun Oct 01 16:39:48 2023 +0200 @@ -13,6 +13,8 @@ HOST="" DOMAIN="" +SESSION="session-read-only" + if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then # Config file can contain the above settings source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" @@ -23,7 +25,7 @@ fi if [[ $# == 0 ]]; then - echo "${0##*/} [-h HOST] [/path] kind=(message|presence|iq) ...." + echo "${0##*/} [-h HOST] [-rw] [/path] kind=(message|presence|iq) ...." # Last arguments are handed to HTTPie, so refer to its docs for further details exit 0 fi @@ -35,6 +37,12 @@ HOST="$(hostname)" fi +if [[ "$1" == "-rw" ]]; then + # To e.g. save Accept headers to the session + SESSION="session" + shift 1 +fi + if [[ "$HOST" != *.* ]]; then # Assumes subdomain of your DOMAIN if [ -z "${DOMAIN:-}" ]; then @@ -55,4 +63,4 @@ shift 1 fi -https --check-status -p b --session rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@" +https --check-status -p b --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@"