Created
May 21, 2012 11:08
-
-
Save yuanchuan/2761842 to your computer and use it in GitHub Desktop.
Quick and dirty way to check if a website is gzipped
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 node | |
/** | |
* Quick and dirty way to check if a website is gzipped | |
* Usage: | |
* ./isgzipped www.xxx.com | |
*/ | |
var exec = require('child_process').exec | |
, site = process.argv[2]; | |
if (site === undefined) { | |
console.log('missing website name.'); | |
return; | |
} | |
exec('curl '+site+' --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}" --output /dev/null', function(err, a) { | |
if (err) throw err; | |
exec('curl '+site+' --silent --write-out "%{size_download}" --output /dev/null', function(err, b) { | |
if (err) throw err; | |
console.log( a !== b); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment