Ruby 为什么有些页面通过 open-uri 取到的 content_type 为 application/octet-stream

siyang1982 · May 27, 2012 · Last by siyang1982 replied at May 27, 2012 · 6390 hits

页面取到的一般是text/html, 而某些网站如http://fontello.com/取到的是application/octet-stream,内容不变。 通过浏览器访问仍是text/html(难道我要在请求时加上浏览器信息?)。

代码如下:

require 'open-uri'

link = 'http://fontello.com/'
url = URI.parse link
puts open(url).content_type

问题是 网站这么做的原因是什么,有什么好处?

rails 无法识别的 MIME 都显示 application/octet-stream;

#1 楼 @mimosa 的确如此,因为响应头里为Transfer-Encoding:chunked 刚才想多了。。。

You need to Sign in before reply, if you don't have an account, please Sign up first.