Class ContentByteRange


  • public class ContentByteRange
    extends Object
    Handles the parsing and validation of HTTP Range headers for Range-based content requests
    Author:
    Bill Branan Date: 4/20/18
    • Constructor Detail

      • ContentByteRange

        public ContentByteRange​(String range)
        Captures the start and end values described in an HTTP Range header
        Parameters:
        range - HTTP Range header with format 'bytes=X-Y'
    • Method Detail

      • getRangeStart

        public Long getRangeStart()
        Gets the starting point of the byte range (the number preceding the "-"), or null if there is no number preceding the dash
      • getRangeEnd

        public Long getRangeEnd()
        Gets the ending point of the byte range (the number following the "-"), or null if there is no number following the dash
      • parseRange

        protected void parseRange​(String range)
        Parses the Range HTTP header value. Only a single range is supported (others are dropped).
        Parameters:
        range - Range header included in HTTP request
        Throws:
        IllegalArgumentException - if range value is not valid
      • getUsage

        public String getUsage​(String range)
        Provides text describing how the Range header value is to be used, and noting that the provided range is invalid.
        Parameters:
        range - invalid range value
        Returns: