Created
October 28, 2021 15:26
-
-
Save marcioadr88/ae146099403219f31a2224edb434575b to your computer and use it in GitHub Desktop.
Compare compressed and uncompressed requests using cURL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
compare() { | |
echo "URI: ${1}" | |
SIZE=$(curl -so /dev/null "${1}" -w '%{size_download}') | |
echo "Uncompressed size : $SIZE bytes" | |
# compressed add the header Accept-Encoding: deflate, gzip, br, zstd | |
SIZE=$(curl --compressed -so /dev/null "${1}" -w '%{size_download}') | |
echo "Compressed size (with --compressed): $SIZE bytes" | |
SIZE=$(curl -H 'Accept-Encoding: gzip, compress, deflate' -so /dev/null "${1}" -w '%{size_download}') | |
echo "Compressed size (with header): $SIZE bytes" | |
} | |
compare $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment