What byte range 0- means

痞子三分冷 提交于 2020-12-13 03:41:09

问题


What "Range: bytes=0-" header means ? Is the entire file ? I tried sending back 0 bytes and is not working, when I send the entire file it works, but I receive this request more than once in a streaming context, it doesn't look right.


回答1:


Is the entire file ?

Yes, exactly that.

The spec has the grammar:

     byte-range-set  = 1#( byte-range-spec / suffix-byte-range-spec )
     byte-range-spec = first-byte-pos "-" [ last-byte-pos ]

and also notes:

If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the representation data, the byte range is interpreted as the remainder of the representation

Additionally:

A client can request the last N bytes of the selected representation using a suffix-byte-range-spec.

     suffix-byte-range-spec = "-" suffix-length

So, valid examples from the spec include:

bytes=-500
bytes=9500-
bytes=0-0,-1

I receive this request more than once in a streaming context

The header indicates that this client understands range requests, and would accept a 206 Partial Content response, rather than the entire file, for efficient streaming (What does the HTTP 206 Partial Content status message mean and how do I fully load resources?).



来源:https://stackoverflow.com/questions/65063701/what-byte-range-0-means

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!