curl 详解

curl 详解

--compressed

--compressed
  (HTTP) Request a compressed response using one of the algorithms
  curl  supports,  and  save  the  uncompressed document.  If this
  option is used and the server  sends  an  unsupported  encoding,
  curl will report an error.
  1. 不指定 header 头,请求返回的结果没有经过压缩
curl -v -o /tmp/ps.js http://e.test.com/assets/vendor/pf/p.js
  1. 保存 /tmp/ps.js 是被gzip压缩过的
curl -v -o /tmp/ps.js http://e.test.com/assets/vendor/pf/p.js -H 'Accept-Encoding: gzip, deflate, sdch'
  1. 使用 --compressed 将会保存解压后的文档到 /tmp/ps.js
curl -v -o /tmp/ps.js http://e.test.com/assets/vendor/pf/p.js -H 'Accept-Encoding: gzip, deflate, sdch' --compressed
  1. 使用 --compressed 将会保存解压后的文档到 /tmp/ps.js,请求头中会添加如下设置: Accept-Encoding: deflate, gzip
curl -v -o /tmp/ps.js http://e.test.com/assets/vendor/pf/p.js --compressed

你可能感兴趣的:(curl 详解)