mathiasbynens/dotfiles — pull request #162 by alrra (2013-01-05 20:52:17+00:00)
Title: Improve `httpcompression`

**Improvements:**

- correctly detects `SDCH` compression according to the [specification](http://www.blogs.zeenor.com/wp-content/uploads/2011/01/Shared_Dictionary_Compression_over_HTTP.pdf)
- correctly overwrites the user agent (use the -A, not the -H option)
- limits the connection and operation time (this is useful for preventing the function from hanging for hours due to slow networks or links going down)
- shows errors
- shows redirects

**Tested on** Mac OS X v.10.8.2 and Ubuntu 12.04 LTS

---

**Examples:**

input
output [old]
output [new]

adobe.com

adobe.com is not using any encoding

adobe.com
↳ http://www.adobe.com/ [gzip]

"http://www.google.com/s?q=alrra&output=search"

http://www.google.com/s?q=alrra&output=search is encoded using gzip

http://www.google.com/s?q=alrra&output=search [sdch,gzip]

firefox.com

firefox.com is encoded using gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip

firefox.com
↳ http://www.firefox.com/
↳ http://www.mozilla.org/firefox/
↳ http://www.mozilla.org/en-US/firefox/new/ [gzip]

google.com/+

google.com/+ is encoded using gzip

google.com/+
↳ http://www.google.com/+
↳ https://plus.google.com/ [gzip]
↳ https://accounts.google.com/ServiceLogin?service=oz&continue=https://plus.google.com/?gpsrc%3Dgplp0&hl=ro [gzip]

sadsada.dsa

sadsada.dsa is not using any encoding

curl: (6) Could not resolve host: sadsada.dsa; nodename nor servname provided, or not known