【问题标题】:Curl does not decompress the deflate pagecurl不解压deflate页面
【发布时间】:2019-10-14 16:04:01
【问题描述】:

由于某些原因,即使设置了 Content-Encoding: deflate 标头,CLI 版本的 Curl 也不会解压缩我的页面。浏览器打开文件就好了。 wget 还解压缩输出。我记得它在一段时间前工作过。 Curl 不解压缩压缩流的原因可能是什么?

$curl app.pitchinvestorslive.com/env.js -i
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 401
Content-Type: text/javascript
Cache-Control: max-age=60
Content-Encoding: deflate
Date: Mon, 14 Oct 2019 14:04:17 GMT
Connection: keep-alive

�(��LY[^T����}L�s�hcyn��w͎*)��ӦԢ�L�k�x��l_c���

$ curl --version
curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1b zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.8.6/openssl/zlib nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 

【问题讨论】:

  • Curl 需要--compressed 来自动解压,没有这个header它只会请求未压缩的网页。
  • curl --compressed app.pitchinvestorslive.com/env.js -i cmd 工作

标签: curl deflate


【解决方案1】:

如果你设置了 --compressed 标志,Curl 会自动解压响应

--压缩

(HTTP) 使用 curl 支持的算法之一请求压缩响应,并保存未压缩的文档。如果使用此选项,服务器发送不支持的编码,curl 会报错。

curl --compressed app.pitchinvestorslive.com/env.js -i 

【讨论】:

    猜你喜欢
    • 2014-12-08
    • 2017-11-08
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 2011-09-06
    • 2020-06-16
    相关资源
    最近更新 更多