curl请求https://segmentfault.com在我本地有效,但在我服务器就不行是为什么?

在我本地是正常的
image.png

但是我服务器里就是这个样子
image.png

不太懂会是什么原因。

本地curl -V

image.png

服务器curl -V
image.png

服务器是CentOS

还有在服务器里 curl https://www.baidu.com 是正常的

主要不明白的点是,为什么本地可以正常返回HTML内容,服务器上却是返回二进制内容?

阅读 3.2k
2 个回答

看返回的header部分,存在content-encoding: gzip,说明服务器强行给你返回了一个gzip压缩过的资源。这种情况其实你可以加上--compressed参数让curl自动解压gzip。

curl --compressed ....

     --compressed    Request compressed response

它的warning说的挺清楚了,Binary output can mess up your terminal 翻译过来是 “二进制输出会弄乱你的终端”

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进