内容范围和范围标头之间的区别?
HTTP 标头 Content-Range
和 Range
之间有什么区别? 每种应该什么时候使用?
我正在尝试从特定字节偏移量流式传输音频文件。 我应该使用 Content-Range
还是 Range
标头?
What is the difference between HTTP headers Content-Range
and Range
? When should each be used?
I am trying to stream an audio file from a particular byte offset. Should I use Content-Range
or Range
header?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,接受的答案并不完整。 Content-Range 不仅仅用于响应。 提供实体机构的请求也是合法的。
例如,HTTP PUT 提供实体主体,它可能仅提供实体的一部分。 因此,PUT 请求可以包括 Content-Range 标头,向服务器指示部分实体主体应在何处合并到实体中。
例如,我们首先使用 HTTP 创建文件,然后附加到文件:
请求 1:
请求 2:
如何,让我们看看文件的内容...
请求 3:
这允许通过 HTTP 进行随机文件访问,包括读取和写入。 我只是想澄清一下,因为我正在研究在我正在开发的 WebDAV 客户端中使用 Content-Range,所以也许这个扩展的信息对其他人有用。
Actually, the accepted answer is not complete. Content-Range is not only used in responses. It is also legal in requests that provide an entity body.
For example, an HTTP PUT provides an entity body, it might provide only a portion of an entity. Thus the PUT request can include a Content-Range header indicating to the server where the partial entity body should be merged into the entity.
For example, let's first create and then append to a file using HTTP:
Request 1:
Request 2:
How, let's see the file's contents...
Request 3:
This allows random file access, both READING and WRITING over HTTP. I just wanted to clarify, as I was researching the use of Content-Range in a WebDAV client I am developing, so perhaps this expanded information will prove useful to somebody else.
Range 用于请求中,以请求特定的字节范围(或多个范围)。 响应中使用 Content-Range 来指示服务器向您提供哪些字节(可能与您请求的范围不同),以及整个内容的长度(如果已知)。
Range is used in the request, to ask for a particular range (or ranges) of bytes. Content-Range is used in the response, to indicate which bytes the server is giving you (which may be different than the range you requested), as well as how long the entire content is (if known).