public void appendData(byte[] data) {
   appendData(data, 0, data.length);
 }
  @Override
  protected void executeRequest(HttpClient httpClient, HttpUriRequest request) {
    Object fullBody = null;
    Throwable error = null;
    HttpResponse response = null;

    try {
      if (request.isAborted()) {
        respondWithResult(
            fullBody,
            new Exception(String.format("%s: Request %s has been aborted", this, request)),
            response);
        return;
      }

      response = httpClient.execute(request);

      try {
        // add in cookies to global store
        if (httpClient instanceof DefaultHttpClient) {
          DefaultHttpClient defaultHttpClient = (DefaultHttpClient) httpClient;
          clientFactory.addCookies(defaultHttpClient.getCookieStore().getCookies());
        }
      } catch (Exception e) {
        Log.e(Log.TAG_REMOTE_REQUEST, "Unable to add in cookies to global store", e);
      }

      StatusLine status = response.getStatusLine();
      if (status.getStatusCode() >= 300) {
        Log.e(
            Log.TAG_REMOTE_REQUEST,
            "Got error status: %d for %s.  Reason: %s",
            status.getStatusCode(),
            request,
            status.getReasonPhrase());
        error = new HttpResponseException(status.getStatusCode(), status.getReasonPhrase());
      } else {
        HttpEntity entity = null;
        try {
          entity = response.getEntity();
          if (entity != null) {
            InputStream inputStream = null;
            try {
              inputStream = entity.getContent();

              Header contentTypeHeader = entity.getContentType();
              if (contentTypeHeader != null) {
                // multipart
                if (contentTypeHeader.getValue().contains("multipart/")) {
                  Log.v(Log.TAG_SYNC, "contentTypeHeader = %s", contentTypeHeader.getValue());
                  _topReader = new MultipartReader(contentTypeHeader.getValue(), this);
                  byte[] buffer = new byte[BUF_LEN];
                  int numBytesRead = 0;
                  while ((numBytesRead = inputStream.read(buffer)) != -1) {
                    _topReader.appendData(buffer, 0, numBytesRead);
                  }
                  _topReader.finished();
                  respondWithResult(fullBody, error, response);
                }
                // non-multipart
                else {
                  Log.v(
                      Log.TAG_SYNC,
                      "contentTypeHeader is not multipart = %s",
                      contentTypeHeader.getValue());
                  GZIPInputStream gzipStream = null;
                  try {
                    // decompress if contentEncoding is gzip
                    if (Utils.isGzip(entity)) {
                      gzipStream = new GZIPInputStream(inputStream);
                      fullBody = Manager.getObjectMapper().readValue(gzipStream, Object.class);
                    } else {
                      fullBody = Manager.getObjectMapper().readValue(inputStream, Object.class);
                    }
                    respondWithResult(fullBody, error, response);
                  } finally {
                    try {
                      if (gzipStream != null) {
                        gzipStream.close();
                      }
                    } catch (IOException e) {
                    }
                    gzipStream = null;
                  }
                }
              }
            } finally {
              try {
                if (inputStream != null) {
                  inputStream.close();
                }
              } catch (IOException e) {
              }
              inputStream = null;
            }
          }
        } finally {
          if (entity != null) {
            try {
              entity.consumeContent();
            } catch (IOException e) {
            }
          }
          entity = null;
        }
      }
    } catch (IOException e) {
      Log.e(Log.TAG_REMOTE_REQUEST, "io exception", e);
      error = e;
    } catch (Exception e) {
      Log.e(Log.TAG_REMOTE_REQUEST, "%s: executeRequest() Exception: ", e, this);
      error = e;
    } finally {
      Log.v(Log.TAG_SYNC, "%s: BulkDownloader finally block.  url: %s", this, url);
    }

    Log.v(
        Log.TAG_SYNC,
        "%s: BulkDownloader calling respondWithResult.  url: %s, error: %s",
        this,
        url,
        error);
    respondWithResult(fullBody, error, response);
  }