code: private <T> T internalExecute(final HttpUriRequest uriRequest, final HttpHost target, final HttpRequest request,
                           final ResponseHandler<? extends T> responseHandler, final HttpContext context)
          throws IOException
      {
          Args.notNull(responseHandler, "Response handler");
  
          final HttpResponse response = (uriRequest != null) ? execute(uriRequest, context) : execute(target, request, context);
  
          final T result;
          try {
              result = responseHandler.handleResponse(response);
          } catch (final Exception t) {
              final HttpEntity entity = response.getEntity();
              try {
                  EntityUtils.consume(entity);
              } catch (final Exception t2) {
                  // Log this exception. The original exception is more
                  // important and will be thrown to the caller.
                  log.warn("Error consuming content after an exception.", t2);
              }
              if (t instanceof RuntimeException) {
                  throw (RuntimeException) t;
              }
              //noinspection ConstantConditions
              if (t instanceof IOException) {
                  throw (IOException) t;
              }
              throw new UndeclaredThrowableException(t);
          }
  
          // Handling the response was successful. Ensure that the content has
          // been fully consumed.
          final HttpEntity entity = response.getEntity();
          EntityUtils.consume(entity);
          return result;
      }
docs: mostly copied from CloseableHttpClient.execute()