@Override
  public byte[] getDigest() {
    if (digest == null) {
      return null;
    } else if (!allContentReceived) {
      throw new IllegalStateException("Cannot calculate digest yet because all the content has not been processed");
    }
    if (digestBytes == null) {
      long startTime = System.currentTimeMillis();
      digestBytes = digest.digest();
      digestCalculationTimeInMs += (System.currentTimeMillis() - startTime);
    }
    return digestBytes;
  }
{@inheritDoc}
<p/>
This function can only be called once the channel has been emptied.
@return the digest as computed by the digest algorithm set through {@link #setDigestAlgorithm(String)}. If none
was set, {@code null}.
@throws IllegalStateException if called before the channel has been emptied.
ambry-rest/src/main/java/com/github/ambry/rest/NettyRequest.java