src/CLI/Downloader.php
protected function readBody( $ch, $string )
	{
		$length	= strlen( $string );														//  get Length of Body Chunk
		$this->loadSize	+= $length;															//  add Length to current Load Length

		if( $this->redirected )
			return $length;																	//  return Length of Header String

		if( $this->showProgress && $this->showProgress )									//  show Progress
		{
			$time	= $this->clock->stop( 6, 0 );											//  get current Duration
			$rate	= $this->loadSize / $time * 1000000;									//  calculate Rate of Bytes per Second
			$rate	= Alg_UnitFormater::formatBytes( $rate, 1 )."/s";						//  format Rate
			if( $this->fileSize )															//  File Size is known
			{
				$ratio	= $this->loadSize / $this->fileSize * 100;							//  calculate Ratio in %
				$ratio	= str_pad( round( $ratio, 0 ), 3, " ", STR_PAD_LEFT );				//  fill Ratio with Spaces
				$size	= Alg_UnitFormater::formatBytes( $this->loadSize, 1 );				//  format current Load Size
				printf( $this->templateBodyRatio, $size, $rate, $ratio );					//  use Template
			}
			else
			{
				$size	= Alg_UnitFormater::formatBytes( $this->loadSize, 1 );				//  format current Load Size
				printf( $this->templateBody, $size, $rate );								//  use Template
			}
		}

		if( $this->fileSize )																//  File Size is known from Header
			$saveUri	= $this->tempUri;													//  save to Temp File
		else																				//  File Size is not known
			$saveUri	= $this->fileUri;													//  save File directly to Save Path

		$fp	= fopen( $saveUri, "ab+" );														//  open File for appending
		fputs( $fp, $string );																//  append Chunk Content
		fclose( $fp );																		//  close File
		
		if( $this->fileSize && $this->fileSize == $this->loadSize )							//  File Size is known and File is complete
		{
			rename( $this->tempUri, $this->fileUri );										//  move Temp File to Save Path
			if( $this->showProgress && $this->templateBodyDone )							//  show Progress
			{
				$fileName	= basename( $this->fileUri );									//  get File Name from File URI
				printf( $this->templateBodyDone, $fileName, $size, $rate );					//  use Template
			}
		}
		return $length;																		//  return Length of Body Chunk
	}
protected function readBody( $ch, $string )
	{
		$length	= strlen( $string );														//  get Length of Body Chunk
		$this->loadSize	+= $length;															//  add Length to current Load Length

		if( $this->redirected )
			return $length;																	//  return Length of Header String

		if( $this->showProgress && $this->showProgress )									//  show Progress
		{
			$time	= $this->clock->stop( 6, 0 );											//  get current Duration
			$rate	= $this->loadSize / $time * 1000000;									//  calculate Rate of Bytes per Second
			$rate	= Alg_UnitFormater::formatBytes( $rate, 1 )."/s";						//  format Rate
			if( $this->fileSize )															//  File Size is known
			{
				$ratio	= $this->loadSize / $this->fileSize * 100;							//  calculate Ratio in %
				$ratio	= str_pad( round( $ratio, 0 ), 3, " ", STR_PAD_LEFT );				//  fill Ratio with Spaces
				$size	= Alg_UnitFormater::formatBytes( $this->loadSize, 1 );				//  format current Load Size
				printf( $this->templateBodyRatio, $size, $rate, $ratio );					//  use Template
			}
			else
			{
				$size	= Alg_UnitFormater::formatBytes( $this->loadSize, 1 );				//  format current Load Size
				printf( $this->templateBody, $size, $rate );								//  use Template
			}
		}

		if( $this->fileSize )																//  File Size is known from Header
			$saveUri	= $this->tempUri;													//  save to Temp File
		else																				//  File Size is not known
			$saveUri	= $this->fileUri;													//  save File directly to Save Path

		$fp	= fopen( $saveUri, "ab+" );														//  open File for appending
		fputs( $fp, $string );																//  append Chunk Content
		fclose( $fp );																		//  close File
		
		if( $this->fileSize && $this->fileSize == $this->loadSize )							//  File Size is known and File is complete
		{
			rename( $this->tempUri, $this->fileUri );										//  move Temp File to Save Path
			if( $this->showProgress && $this->templateBodyDone )							//  show Progress
			{
				$fileName	= basename( $this->fileUri );									//  get File Name from File URI
				printf( $this->templateBodyDone, $fileName, $size, $rate );					//  use Template
			}
		}
		return $length;																		//  return Length of Body Chunk
	}
protected function readBody ( $ ch , $ string ) { $ length = strlen ( $ string ) ; //  get Length of Body Chunk $ this -> loadSize += $ length ; //  add Length to current Load Length if ( $ this -> redirected ) return $ length ; //  return Length of Header String if ( $ this -> showProgress && $ this -> showProgress ) //  show Progress { $ time = $ this -> clock -> stop ( 6 , 0 ) ; //  get current Duration $ rate = $ this -> loadSize / $ time * 1000000 ; //  calculate Rate of Bytes per Second $ rate = Alg_UnitFormater :: formatBytes ( $ rate , 1 ) . "/s" ; //  format Rate if ( $ this -> fileSize ) //  File Size is known { $ ratio = $ this -> loadSize / $ this -> fileSize * 100 ; //  calculate Ratio in % $ ratio = str_pad ( round ( $ ratio , 0 ) , 3 , " " , STR_PAD_LEFT ) ; //  fill Ratio with Spaces $ size = Alg_UnitFormater :: formatBytes ( $ this -> loadSize , 1 ) ; //  format current Load Size printf ( $ this -> templateBodyRatio , $ size , $ rate , $ ratio ) ; //  use Template } else { $ size = Alg_UnitFormater :: formatBytes ( $ this -> loadSize , 1 ) ; //  format current Load Size printf ( $ this -> templateBody , $ size , $ rate ) ; //  use Template } } if ( $ this -> fileSize ) //  File Size is known from Header $ saveUri = $ this -> tempUri ; //  save to Temp File else //  File Size is not known $ saveUri = $ this -> fileUri ; //  save File directly to Save Path $ fp = fopen ( $ saveUri , "ab+" ) ; //  open File for appending fputs ( $ fp , $ string ) ; //  append Chunk Content fclose ( $ fp ) ; //  close File if ( $ this -> fileSize && $ this -> fileSize == $ this -> loadSize ) //  File Size is known and File is complete { rename ( $ this -> tempUri , $ this -> fileUri ) ; //  move Temp File to Save Path if ( $ this -> showProgress && $ this -> templateBodyDone ) //  show Progress { $ fileName = basename ( $ this -> fileUri ) ; //  get File Name from File URI printf ( $ this -> templateBodyDone , $ fileName , $ size , $ rate ) ; //  use Template } } return $ length ; //  return Length of Body Chunk }
Callback Method for reading Body Chunks.
@access		protected
@param		resource	$ch			cURL Handle
@param		string		$string		Body Chunk Content
@return		int
Callback Method for reading Body Chunks .