如何绕过 HTTParty 无效代码长度集(Zlib::DataError)?
How to get around HTTParty invalid code lengths set (Zlib::DataError)?
当向 URL 发送一个 HTTParty.get()
请求重定向到另一个(一个,或可能更多)URL(s) 时,我得到这个错误:
Zlib::DataError:
invalid code lengths set
# ./file/file_name.rb:63:in `block (3 levels) in <top (required)>'
我该如何解决这个问题,为什么会这样?
将 headers 选项中的 Accept-Encoding
参数设置为空白:
resp = HTTParty.get(article.old_url, :verify => false, :headers => {'Accept-Encoding' => ''})
HTTPParty 在解压缩响应时遇到错误(特别是 gzip in my case), possibly because something strange was happening with the received Content-Type
header 作为重定向的结果。将 Accept-Encoding header 设置为空白会返回一些内容HTTParty 知道如何解析。
当向 URL 发送一个 HTTParty.get()
请求重定向到另一个(一个,或可能更多)URL(s) 时,我得到这个错误:
Zlib::DataError:
invalid code lengths set
# ./file/file_name.rb:63:in `block (3 levels) in <top (required)>'
我该如何解决这个问题,为什么会这样?
将 headers 选项中的 Accept-Encoding
参数设置为空白:
resp = HTTParty.get(article.old_url, :verify => false, :headers => {'Accept-Encoding' => ''})
HTTPParty 在解压缩响应时遇到错误(特别是 gzip in my case), possibly because something strange was happening with the received Content-Type
header 作为重定向的结果。将 Accept-Encoding header 设置为空白会返回一些内容HTTParty 知道如何解析。