Created
October 12, 2019 14:00
-
-
Save gorshunovr/8194b318aebb963838e146c606b0a447 to your computer and use it in GitHub Desktop.
Rackspace CDN Content-Encoding headers demo
This file contains 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 | |
URL="https://2365c1d014187c3ae706-2572cddac5187c7b669ab9398e41b48d.ssl.cf5.rackcdn.com/687536/4/check/openstack-tox-docs/eb49c40/" | |
UA="User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15" | |
ACCEPT="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" | |
ACCEPT_LANG="Accept-Language: en-us" | |
ACCEPT_ENC="Accept-Encoding: gzip, deflate, br" | |
PERL_ZLIB_DECODER='use Compress::Raw::Zlib;my $d=new Compress::Raw::Zlib::Inflate();my $o;undef $/;$d->inflate(<>,$o);print $o;' | |
echo "This is correct behaviour:" | |
curl -v \ | |
-o output-1.zlib.data \ | |
-H "${UA}" \ | |
-H "${ACCEPT}" \ | |
-H "${ACCEPT_LANG}" \ | |
-H "${ACCEPT_ENC}" \ | |
"${URL}" 2>&1 | grep Encoding | |
file output-1.zlib.data | |
cat output-1.zlib.data | perl -e "${PERL_ZLIB_DECODER}" > output-1.html | |
file output-1.html | |
URL="${URL}docs/" | |
echo | |
echo "This is incorrect behaviour:" | |
curl -v \ | |
-o output-2.gzip.data \ | |
-H "${UA}" \ | |
-H "${ACCEPT}" \ | |
-H "${ACCEPT_LANG}" \ | |
-H "${ACCEPT_ENC}" \ | |
"${URL}" 2>&1 | grep Encoding | |
file output-2.gzip.data | |
gzip -dc output-2.gzip.data > output-2.zlib.data | |
file output-2.zlib.data | |
cat output-2.zlib.data | perl -e "${PERL_ZLIB_DECODER}" > output-2.html | |
file output-2.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment