Class ContentRangeParser

java.lang.Object
software.amazon.awssdk.transfer.s3.internal.progress.ContentRangeParser

public final class ContentRangeParser extends Object
Parse a Content-Range header value into a total byte count. The expected format is the following:

Content-Range: <unit> <range-start>-<range-end>\/<size>
Content-Range: <unit> <range-start>-<range-end>\/*
Content-Range: <unit> *\/<size>

The only supported <unit> is the bytes value.

  • Method Details

    • totalBytes

      public static OptionalLong totalBytes(String contentRange)
      Parse the Content-Range to extract the total number of byte from the content. Only supports the bytes unit, any other unit will result in an empty OptionalLong. If the total length in unknown, which is represented by a * symbol in the header value, an empty OptionalLong will be returned.
      Parameters:
      contentRange - the value of the Content-Range header to be parsed.
      Returns:
      The total number of bytes in the content range or an empty optional if the contentRange is null, empty or if the total length is not a valid long.