@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());
    }
  }
 @Override
 public void setStatus(int status) {
   this.statusType = ResponseImpl.toStatusType(status);
 }