code: long checkRangeSupport(URI uri) throws IOException {
      HttpRequestBase req = createReq(uri, true);
      try (CloseableHttpClient client = HttpClientBuilder.create().build();
           CloseableHttpResponse response = client.execute(req)) {
        Header acceptRangesHeader = response.getFirstHeader(HttpHeaders.ACCEPT_RANGES);
        Header contentLengthHeader = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
        boolean acceptByteRange = (acceptRangesHeader != null) && "bytes".equalsIgnoreCase(acceptRangesHeader.getValue());
        if (!acceptByteRange || contentLengthHeader == null) {
          return -1L;
        }
  
        return Long.valueOf(contentLengthHeader.getValue());
      }
    }
docs: Tests whether a given URI can be accessed using range-requests.
  
  @param uri resource identifier
  @return -1 if range-requests are not supported, otherwise content length of the requested resource
  @throws IOException when communication fails