Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active October 16, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/d16924d70b14502cbe5bb443ac62a09b to your computer and use it in GitHub Desktop.
Save Integralist/d16924d70b14502cbe5bb443ac62a09b to your computer and use it in GitHub Desktop.
[Bash string wildcard glob conains example] #bash #wildcard #glob #contains
#!/bin/bash
# our CDN was serving stale content for a request that shouldn't be
# so we wrote a quick script to verify the behaviour wasn't happening
# more often than it should.
function get {
local id=$1
local url="https://www.example.com/?id=$id"
local response=$(curl -D - -so /dev/null -H 'X-Debug:1' "$url")
local state=$(echo "$response" | grep 'Foo-State')
echo "$state"
}
for i in {1..50}
do
uid="attempt-$i-$(uuidgen)"
result1=$(get "$uid")
result2=$(get "$uid")
if [[ "$result2" == *"HIT-STALE"* ]]; then
echo "$uid: got stale :-("
elif [[ "$result2" == *"HIT-"* ]]; then
echo "$uid: was fine :-)"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment