code: public static HttpEntity checkAndFetch(HttpResponse response, String url) throws IOException {
          int statusCode = response.getStatusLine().getStatusCode();
          if(statusCode > 206) {
  			String msg = "Had HTTP StatusCode " + statusCode + " for request: " + url + ", response: " +
  					response.getStatusLine().getReasonPhrase() + "\n" +
  					StringUtils.abbreviate(IOUtils.toString(response.getEntity().getContent(), "UTF-8"), 1024);
              log.warning(msg);
  
              throw new IOException(msg);
          }
  
          return response.getEntity();
  	}
docs: Helper method to check the status code of the response and throw an IOException if it is
  an error or moved state.
  
  @param response A HttpResponse that is resulting from executing a HttpMethod.
  @param url The url, only used for building the error message of the exception.
  
  @return The {@link HttpEntity} returned from response.getEntity().
  
  @throws IOException if the HTTP status code is higher than 206.