private void verifyHeadersForGetBlob(RestRequest restRequest, BlobInfo blobInfo,
      Pair<Account, Container> accountAndContainer, ByteRange range, MockRestResponseChannel restResponseChannel)
      throws RestServiceException {
    BlobProperties blobProperties = blobInfo.getBlobProperties();
    Assert.assertEquals("Blob size mismatch ", blobProperties.getBlobSize(),
        Long.parseLong(restResponseChannel.getHeader(RestUtils.Headers.BLOB_SIZE)));
    if (blobProperties.getContentType() != null) {
      Assert.assertEquals("Content Type mismatch", blobProperties.getContentType(),
          restResponseChannel.getHeader(RestUtils.Headers.CONTENT_TYPE));
      if (blobProperties.getContentType().equals("text/html")) {
        Assert.assertEquals("Content disposition not set for text/html Content type", "attachment",
            restResponseChannel.getHeader("Content-Disposition"));
      } else {
        Assert.assertNull("Content disposition should not have been set",
            restResponseChannel.getHeader("Content-Disposition"));
      }
    }

    Assert.assertEquals("Accept ranges header not set correctly", "bytes",
        restResponseChannel.getHeader(RestUtils.Headers.ACCEPT_RANGES));
    long contentLength = blobProperties.getBlobSize();
    if (range != null) {
      Pair<String, Long> rangeAndLength = RestUtils.buildContentRangeAndLength(range, contentLength, false);
      Assert.assertEquals("Content range header not set correctly for range " + range, rangeAndLength.getFirst(),
          restResponseChannel.getHeader(RestUtils.Headers.CONTENT_RANGE));
      contentLength = rangeAndLength.getSecond();
    } else {
      Assert.assertNull("Content range header should not be set",
          restResponseChannel.getHeader(RestUtils.Headers.CONTENT_RANGE));
    }

    if (contentLength < FRONTEND_CONFIG.chunkedGetResponseThresholdInBytes) {
      Assert.assertEquals("Content length value mismatch", contentLength,
          Integer.parseInt(restResponseChannel.getHeader(RestUtils.Headers.CONTENT_LENGTH)));
    } else {
      Assert.assertNull("Content length value should not be set",
          restResponseChannel.getHeader(RestUtils.Headers.CONTENT_LENGTH));
    }

    if (range != null) {
      Assert.assertEquals("Content length value mismatch in internal header", contentLength,
          Long.parseLong(RestUtils.getHeader(restRequest.getArgs(), CONTENT_RANGE_LENGTH, false)));
    } else {
      Assert.assertNull("", RestUtils.getHeader(restRequest.getArgs(), CONTENT_RANGE_LENGTH, false));
    }

    verifyBlobPropertiesHeaders(blobInfo.getBlobProperties(), restResponseChannel);
    verifyAccountAndContainerHeaders(restResponseChannel, accountAndContainer.getFirst(),
        accountAndContainer.getSecond());
    Assert.assertEquals("LifeVersion mismatch", Short.toString(blobInfo.getLifeVersion()),
        restResponseChannel.getHeader(RestUtils.Headers.LIFE_VERSION));
    Map<String, String> userMetadata =
        blobInfo.getUserMetadata() != null ? RestUtils.buildUserMetadata(blobInfo.getUserMetadata()) : null;
    if (blobInfo.getUserMetadata().length == 0 || userMetadata == null) {
      Assert.assertNull(
          "Internal key " + RestUtils.InternalKeys.SEND_USER_METADATA_AS_RESPONSE_BODY + " should not be set",
          restRequest.getArgs().get(RestUtils.InternalKeys.SEND_USER_METADATA_AS_RESPONSE_BODY));
    } else {
      Set<String> keysToNotPrefix = accountAndContainer.getSecond().getUserMetadataKeysToNotPrefixInResponse();
      for (Map.Entry<String, Object> entry : USER_METADATA.entrySet()) {
        String key = entry.getKey();
        String value = (String) entry.getValue();
        String keyWithoutPrefix = key.substring(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX.length());
        if (keysToNotPrefix.contains(keyWithoutPrefix)) {
          Assert.assertEquals("Value of " + key + " not as expected", value,
              restResponseChannel.getHeader(keyWithoutPrefix));
        } else {
          Assert.assertEquals("Value of " + key + " not as expected", value, restResponseChannel.getHeader(key));
        }
      }
    }
    verifyCacheHeaders(accountAndContainer.getSecond(), restResponseChannel);
  }
Verify the headers from the response are as expected
@param restRequest the original request received.
@param blobInfo the {@link BlobInfo} to refer to while getting headers.
@param accountAndContainer the {@link Account} and {@link Container} of the blob being requested.
@param range the {@link ByteRange} used for a range request, or {@code null} for non-ranged requests.
@param restResponseChannel {@link MockRestResponseChannel} from which headers are to be verified
@throws RestServiceException if there was any problem getting the headers.
ambry-frontend/src/test/java/com/github/ambry/frontend/AmbrySecurityServiceTest.java