public static byte[] responseToBytes(KJHttpResponse response)
      throws IOException, KJHttpException {
    PoolingByteArrayOutputStream bytes =
        new PoolingByteArrayOutputStream(ByteArrayPool.get(), (int) response.getContentLength());
    byte[] buffer = null;
    try {
      InputStream in = response.getContentStream();
      if (isGzipContent(response) && !(in instanceof GZIPInputStream)) {
        in = new GZIPInputStream(in);
      }

      if (in == null) {
        throw new KJHttpException("服务器连接异常");
      }

      buffer = ByteArrayPool.get().getBuf(1024);
      int count;
      while ((count = in.read(buffer)) != -1) {
        bytes.write(buffer, 0, count);
      }
      return bytes.toByteArray();
    } finally {
      try {
        // Close the InputStream and release the resources by
        // "consuming the content".
        //                entity.consumeContent();
        response.getContentStream().close();
      } catch (IOException e) {
        // This can happen if there was an exception above that left the
        // entity in
        // an invalid state.
        KJLoger.debug("Error occured when calling consumingContent");
      }
      ByteArrayPool.get().returnBuf(buffer);
      bytes.close();
    }
  }