--- 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" "$@"