public int getResponseData() {
    if (responseData != null && responseDataKey == -1) {
      TitaniumModuleManager tmm = weakTmm.get();
      if (tmm != null) {
        TitaniumMemoryBlob blob = new TitaniumMemoryBlob(responseData);
        responseDataKey = tmm.cacheObject(blob);
      }
    } else {
      responseDataKey = -1;
    }

    return responseDataKey;
  }
    public String handleResponse(HttpResponse response) throws HttpResponseException, IOException {
      String clientResponse = null;

      if (client != null) {
        TitaniumHttpClient c = client.get();
        if (c != null) {
          c.response = response;
          c.setReadyState(READY_STATE_LOADED, syncId);
          c.setStatus(response.getStatusLine().getStatusCode());
          c.setStatusText(response.getStatusLine().getReasonPhrase());
          c.setReadyState(READY_STATE_INTERACTIVE, syncId);
        }

        if (DBG) {
          try {
            Log.w(LCAT, "Entity Type: " + response.getEntity().getClass());
            Log.w(LCAT, "Entity Content Type: " + response.getEntity().getContentType().getValue());
            Log.w(LCAT, "Entity isChunked: " + response.getEntity().isChunked());
            Log.w(LCAT, "Entity isStreaming: " + response.getEntity().isStreaming());
          } catch (Throwable t) {
            // Ignore
          }
        }

        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() >= 300) {
          throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
        }

        entity = response.getEntity();

        if (c.onDataStreamCallback != null) {
          is = entity.getContent();

          if (is != null) {
            final String cb = c.onDataStreamCallback;
            final TitaniumWebView webView = softWebView.get();

            long contentLength = entity.getContentLength();
            if (DBG) {
              Log.d(LCAT, "Content length: " + contentLength);
            }
            int count = 0;
            int totalSize = 0;
            byte[] buf = new byte[4096];
            if (DBG) {
              Log.d(LCAT, "Available: " + is.available());
            }
            if (aborted) {
              if (entity != null) {
                entity.consumeContent();
              }
            } else {
              while ((count = is.read(buf)) != -1) {
                totalSize += count;
                if (webView != null) {
                  TitaniumModuleManager tmm = weakTmm.get();
                  if (tmm != null) {
                    try {
                      JSONObject o = new JSONObject();
                      o.put("totalCount", contentLength);
                      o.put("totalSize", totalSize);
                      o.put("size", count);
                      byte[] newbuf = new byte[count];
                      for (int i = 0; i < count; i++) {
                        newbuf[i] = buf[i];
                      }
                      TitaniumMemoryBlob blob = new TitaniumMemoryBlob(newbuf);
                      int key = tmm.cacheObject(blob);
                      o.put("key", key);
                      webView.evalJS(cb, o.toString(), syncId);
                    } catch (JSONException e) {
                      Log.e(LCAT, "Unable to send ondatastream event: ", e);
                    }
                  }
                }
                if (!entity.isStreaming()) {
                  break;
                }
              }
              if (entity != null) {
                entity.consumeContent();
              }
            }
          }
        } else {
          setResponseData(entity);
        }
      }
      return clientResponse;
    }