1#!/usr/bin/env bash 2# What each host says to a few things a device could send, headers included, for comparing hosts by eye. 3# 4# mise run backend:probe -- <native|wrangler|celld> 5set -euo pipefail 6here="$(cd "$(dirname "$0")" && pwd)" 7h="${1:?native, wrangler or celld}" 8case "$h" in celld) p=8801;; wrangler) p=8802;; native) p=8803;; *) exit 2;; esac 9"$here/host" "$h" fresh >/dev/null 10trap '"$here/host" "$h" stop' EXIT 11curl_() { curl -s --noproxy '*' "$@"; } 12echo "=== $h" 13echo "-- a sync (200), headers:"; curl_ -D - -o /dev/null -X POST -H 'x-whiskers-household: probe1' -d '{"facts":[],"forgotten":[]}' "localhost:$p/memory/sync" 14echo "-- GET (405), headers:"; curl_ -D - -o /dev/null -X GET "localhost:$p/memory/sync" 15echo "-- unknown route (404), headers:"; curl_ -D - -o /dev/null -X POST "localhost:$p/nope" 16echo "-- /journal/pull (not on the Worker yet):"; curl_ -i -X POST -H 'x-whiskers-household: probe1' -d '{"since":0}' "localhost:$p/journal/pull" | head -8 17echo "-- /usage:"; curl_ -i -X POST -H 'x-whiskers-household: probe1' -d '{}' "localhost:$p/usage" | head -8 18echo "-- a household header that is not an id:"; curl_ -i -X POST -H 'x-whiskers-household: Bad_ID' -d '{"facts":[],"forgotten":[]}' "localhost:$p/memory/sync" | head -6 19echo "-- a bad body (to see the log level used):"; curl_ -o /dev/null -w '%{http_code}\n' -X POST -H 'x-whiskers-household: probe1' -d 'x' "localhost:$p/memory/sync" 20echo "-- log lines about it:"; grep -iE "not a valid|does not read|bad request|memory/sync" "${WHISKERS_SPIKE_STATE:-/tmp/whiskers-cellflare}/$h.log" | grep -v ltx_repl | tail -4 | cut -c1-260