问题描述
是否有任何方法可以使curl压缩而无需在请求中发送Accept-encoding标头?
Is there any way to get curl to decompress a response without sending the Accept-encoding headers in the request?
我正在尝试调试接受编码标头的顺序可能是相关的,但我还需要知道响应是什么。如果我只发送 -H'Accept-encoding:gzip
并且服务器gzip响应,则curl不会解压缩它。
I'm trying to debug an issue where the order of the Accept-encoding headers may be relevant, but I also need to know what the response is. If I just send -H 'Accept-encoding: gzip
and the server gzips the response, curl won't decompress it.
推荐答案
可能最简单的方法就是使用 gunzip
来做到这一点:
Probably the easiest thing to do is just use gunzip
to do it:
curl -sH 'Accept-encoding: gzip' http://example.com/ | gunzip -
或者还有压缩的
, curl
将解压缩(我相信),因为它知道响应已压缩。但是,不确定是否满足您的需求。
Or there's also --compressed
, which curl
will decompress (I believe) since it knows the response is compressed. But, not sure if that meets your needs.
这篇关于有什么方法可以使curl解压缩响应而不在请求中发送Accept标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!