@Override
  public Optional<BlobDescriptor> handleResponse(Response response) throws RegistryErrorException {
    long contentLength = response.getContentLength();
    if (contentLength < 0) {
      throw new RegistryErrorExceptionBuilder(getActionDescription())
          .addReason("Did not receive Content-Length header")
          .build();
    }

    return Optional.of(new BlobDescriptor(contentLength, blobDigest));
  }
@Test
  public void testHandleResponse_noContentLength() {
    Mockito.when(mockResponse.getContentLength()).thenReturn(-1L);

    try {
      testBlobChecker.handleResponse(mockResponse);
      Assert.fail("Should throw exception if Content-Length header is not present");

    } catch (RegistryErrorException ex) {
      MatcherAssert.assertThat(
          ex.getMessage(), CoreMatchers.containsString("Did not receive Content-Length header"));
    }
  }