Can I use the HTTP range header to load partial files quot;on purposequot;?(我可以使用 HTTP 范围标头“故意加载部分文件吗?)
问题描述
我正在使用 HTTP 范围标头(规范).
I'm playing around with the HTTP range header (specs).
据我了解,我可以设置文件的字节范围 ala
From what I understand I can set byte ranges of files ala
0-199/2000
200-499/2000
500-799/2000
etc
问题:
假设我只想访问文件的某些范围,是否可以指定这些范围,然后使用我收到的不完整"数据?我正在过滤一个大的日志文件,所以我很好奇这样的事情是否可行.
Question:
Say I only want to access certain ranges of a file, would it be possible to specify these ranges and then work with the "incomplete" data I received? I'm playing around with filtering a large log file, so I'm curious if something like this would work.
感谢您的意见!
推荐答案
你是对的,你在评论中发布的链接可能是最好的方法.因为你的问题听起来很有趣,所以我试了一下.你可能做到了,但这里有一个片段(可能会看到其他片段)
You are right the link which you posted in the comment would be probably the best approche. As your question sounded interesting i tried it out. You probably did it, but here is an snippet(for other that may come looking)
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","data.dat",false);
xmlhttp.setRequestHeader("Range", "bytes=100-200");
xmlhttp.send();
console.info(xmlhttp); //--> returns only the partial content
// Tested on Win7 with chrome 46+
这篇关于我可以使用 HTTP 范围标头“故意"加载部分文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以使用 HTTP 范围标头“故意"加载部分文件吗?


基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01