恢复Ruby中的文件下载,范围标题问题 [英] Resuming file downloads in Ruby, range header issue
本文介绍了恢复Ruby中的文件下载,范围标题问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ruby 1.8.7中设置范围标题时,会添加一个额外的X-REMOVED:Range标题,这(看似)会阻止下载恢复工作。
When setting a range header in Ruby 1.8.7, an additional "X-REMOVED: Range" header is being added, which (seemingly) prevents download resumes from working.
size = File.size(local_file)
Net::HTTP.start(domain) do |http|
headers = {
'Range' => "bytes=#{size}-"
}
resp = http.get(remote_file, headers)
open(local_file, "wb") do |file|
file.write(resp.body)
end
end
已发送标题:
GET /test.zip HTTP/1.1..Host: 192.168.50.1..Accept: */*..X-REMOVED: Range..Range: bytes=481-....
我'我也尝试使用具有相同结果的set_range。
I've also tried using set_range with the same result.
推荐答案
这很令人尴尬。恢复不起作用与范围标题无关。只是我用wb而不是ab打开文件。
Well this is embarrassing. The resumes not working had nothing to do with the range header. It's just that I was opening the file with "wb" instead of "ab".
这篇关于恢复Ruby中的文件下载,范围标题问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文