private byte[] entityToBytes(Request<?> request,HttpEntity entity) throws IOException, ServerError {
  PoolingByteArrayOutputStream bytes=new PoolingByteArrayOutputStream(mPool,(int)entity.getContentLength());
  byte[] buffer=null;
  long totalSize=(int)entity.getContentLength();
  try {
    ProgressListener progressListener=null;
    if (request instanceof ProgressListener) {
      progressListener=(ProgressListener)request;
    }
    InputStream in=entity.getContent();
    if (in == null) {
      throw new ServerError();
    }
    buffer=mPool.getBuf(1024);
    int count;
    int transferredBytes=0;
    while ((count=in.read(buffer)) != -1) {
      bytes.write(buffer,0,count);
      transferredBytes+=count;
      if (null != progressListener) {
        progressListener.onProgress(transferredBytes,totalSize);
      }
    }
    return bytes.toByteArray();
  }
  finally {
    try {
      entity.consumeContent();
    }
 catch (    IOException e) {
      VolleyLog.v("Error occured when calling consumingContent");
    }
    mPool.returnBuf(buffer);
    bytes.close();
  }
}

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