code: public CloseableHttpResponse getCloseableHttpResponse() {
          ContentType resultContentType = null;
          if (this.contentType != null) {
              resultContentType = ContentType.create(this.contentType, characterEncoding);
          }
          if (internalWriter != null) {
              writer.flush();
              httpClientResponse.setEntity(new StringEntity(internalWriter.toString(), resultContentType));
          } else if (internalOutputStream != null) {
              try {
                  outputStream.flush();
              } catch (IOException e) {
                  // Nothing to do;
              }
              httpClientResponse.setEntity(new ByteArrayEntity(internalOutputStream.toByteArray(), resultContentType));
          }
          if (!capture) {
              // The result has already been written to the response, let's close
              // the response stream
              if (responseWriter != null) {
                  responseWriter.close();
              }
              if (responseOutputStream != null) {
                  try {
                      responseOutputStream.close();
                  } catch (IOException e) {
                      LOG.warn("Could not close servlet output stream: " + e.getMessage());
                  }
              }
          }
          return httpClientResponse;
      }
docs: Returns the response. If the response has not been captured and has been written directly to the
  {@link HttpServletResponse}, calling this method closes the HttpServletResponse writer OutputStream
  
  @return the response