protected void addContent(HttpContent httpContent) throws RestServiceException {
    if (!getRestMethod().equals(RestMethod.POST) && !getRestMethod().equals(RestMethod.PUT) && (
        !(httpContent instanceof LastHttpContent) || httpContent.content().readableBytes() > 0)) {
      throw new IllegalStateException("There is no content expected for " + getRestMethod());
    } else {
      validateState(httpContent);
      contentLock.lock();
      try {
        int size = httpContent.content().readableBytes();
        if (!isOpen()) {
          nettyMetrics.requestAlreadyClosedError.inc();
          throw new RestServiceException("The request has been closed and is not accepting content",
              RestServiceErrorCode.RequestChannelClosed);
        } else if (writeChannel != null) {
          writeContent(writeChannel, callbackWrapper, httpContent);
          continueReadIfPossible(size);
        } else {
          requestContents.add(httpContent.retain());
          continueReadIfPossible(size);
        }
      } finally {
        contentLock.unlock();
      }
    }
  }
Adds some content in the form of {@link HttpContent} to this RestRequest. This content will be available to read
through the read operations.
@param httpContent the {@link HttpContent} that needs to be added.
@throws IllegalStateException if content is being added when it is not expected (GET, DELETE, HEAD).
@throws RestServiceException if request channel has been closed.
ambry-rest/src/main/java/com/github/ambry/rest/NettyRequest.java