Skip to content

Instantly share code, notes, and snippets.

@lidel
Created July 12, 2019 12:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lidel/3f8b05b52da373320b07f248972dbb1d to your computer and use it in GitHub Desktop.
Save lidel/3f8b05b52da373320b07f248972dbb1d to your computer and use it in GitHub Desktop.
Quick script to check if HTTP server supports compression
#!/bin/bash
set -euo pipefail
if [ $# -ne 1 ]; then
echo 1>&2 "Usage: $0 URL"
exit 3
fi
echo "Checking $1"
curl -L -I -H "Accept-Encoding: gzip,deflate,br" "$1" --silent | grep -i "Content-Encoding:" || echo "Content-Encoding not found in response"
echo -ne "compressed:\t"
curl -L -H "Accept-Encoding: gzip,deflate,br" "$1" --silent --write-out "%{size_download}" --output /dev/null
echo -ne "\nuncompressed:\t"
curl -L "$1" --silent --write-out "%{size_download}" --output /dev/null
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment