private byte[] entityToBytes(HttpEntity entity,Request request) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes=new PoolingByteArrayOutputStream(mPool,(int)entity.getContentLength());
  byte[] buffer=null;
  try {
    InputStream in=entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer=mPool.getBuf(1024);
    int progress=0;
    int count;
    while ((count=in.read(buffer)) != -1) {
      bytes.write(buffer,0,count);
      progress+=count;
      request.progressUpdate(progress);
    }
    return bytes.toByteArray();
  }
  finally {
    try {
      entity.consumeContent();
    }
 catch (    IOException e) {
      VinciLog.d("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}

private byte [ ] entityToBytes ( HttpEntity entity , Request request ) throws IOException , ServerError { PoolingByteArrayOutputStream bytes = new PoolingByteArrayOutputStream ( mPool , ( int ) entity . getContentLength ( ) ) ; byte [ ] buffer = null ; try { InputStream in = entity . getContent ( ) ; if ( in == null ) { throw new ServerError ( ) ; } buffer = mPool . getBuf ( 1024 ) ; int progress = 0 ; int count ; while ( ( count = in . read ( buffer ) ) != - 1 ) { bytes . write ( buffer , 0 , count ) ; progress += count ; request . progressUpdate ( progress ) ; } return bytes . toByteArray ( ) ; } finally { try { entity . consumeContent ( ) ; } catch ( IOException e ) { VinciLog . d ( "Error occured when calling consumingContent" ) ; } mPool . returnBuf ( buffer ) ; bytes . close ( ) ; } }
reads the contents of httpentity into a byte [ ] .
