private HttpResponse executeCurrentRequest(long currentRequestLastBytePos, GenericUrl requestUrl,
      HttpHeaders requestHeaders, OutputStream outputStream) throws IOException {
    // prepare the GET request
    HttpRequest request = requestFactory.buildGetRequest(requestUrl);
    // add request headers
    if (requestHeaders != null) {
      request.getHeaders().putAll(requestHeaders);
    }
    // set Range header (if necessary)
    if (bytesDownloaded != 0 || currentRequestLastBytePos != -1) {
      StringBuilder rangeHeader = new StringBuilder();
      rangeHeader.append("bytes=").append(bytesDownloaded).append("-");
      if (currentRequestLastBytePos != -1) {
        rangeHeader.append(currentRequestLastBytePos);
      }
      request.getHeaders().setRange(rangeHeader.toString());
    }
    // execute the request and copy into the output stream
    HttpResponse response = request.execute();
    try {
      ByteStreams.copy(response.getContent(), outputStream);
    } finally {
      response.disconnect();
    }
    return response;
  }
private HttpResponse executeCurrentRequest ( long currentRequestLastBytePos , GenericUrl requestUrl , HttpHeaders requestHeaders , OutputStream outputStream ) throws IOException { HttpRequest request = requestFactory . buildGetRequest ( requestUrl ) ; if ( requestHeaders != null ) { request . getHeaders ( ) . putAll ( requestHeaders ) ; } if ( bytesDownloaded != 0 || currentRequestLastBytePos != - 1 ) { StringBuilder rangeHeader = new StringBuilder ( ) ; rangeHeader . append ( "bytes=" ) . append ( bytesDownloaded ) . append ( "-" ) ; if ( currentRequestLastBytePos != - 1 ) { rangeHeader . append ( currentRequestLastBytePos ) ; } request . getHeaders ( ) . setRange ( rangeHeader . toString ( ) ) ; } HttpResponse response = request . execute ( ) ; try { ByteStreams . copy ( response . getContent ( ) , outputStream ) ; } finally { response . disconnect ( ) ; } return response ; }
Executes the current request.

@param currentRequestLastBytePos last byte position for current request
@param requestUrl request URL where the download requests will be sent
@param requestHeaders request headers or {@code null} to ignore
@param outputStream destination output stream
@return HTTP response