httphttp-1.1http-range

What byte range 0- means


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.


Solution

  • 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?).