@Override
  public void setResponse(Response response) {
    this.isCommitted = false;
    this.out = null;
    this.response = response = (response != null) ? response : Responses.noContent().build();
    this.mappedThrowable = null;

    if (response instanceof ResponseImpl) {
      final ResponseImpl responseImpl = (ResponseImpl) response;
      setStatusType(responseImpl.getStatusType());
      setHeaders(response.getMetadata());
      setEntity(responseImpl.getEntity(), responseImpl.getEntityType());
    } else {
      setStatus(response.getStatus());
      setHeaders(response.getMetadata());
      setEntity(response.getEntity());
    }
  }
 /** Reset the response to 204 (No content) with no headers. */
 public void reset() {
   setResponse(Responses.noContent().build());
 }