| | |
| | if( $real && strpos( $real, $repo ) === 0 ) { |
| | - $result = readfile( $path ) !== false; |
| | + $result = $this->streamFileContent( $path ); |
| | + } |
| | + } |
| | + } |
| | + |
| | + return $result; |
| | + } |
| | + |
| | + private function streamFileContent( string $path ): bool { |
| | + $result = false; |
| | + $handle = fopen( $path, 'rb' ); |
| | + |
| | + if( $handle !== false ) { |
| | + ignore_user_abort( true ); |
| | + set_time_limit( 0 ); |
| | + |
| | + while( !feof( $handle ) && connection_aborted() === 0 ) { |
| | + $chunk = fread( $handle, 8192 ); |
| | + |
| | + if( $chunk !== false && $chunk !== '' ) { |
| | + echo $chunk; |
| | + |
| | + if( ob_get_level() > 0 ) { |
| | + ob_flush(); |
| | + } |
| | + |
| | + flush(); |
| | } |
| | } |
| | + |
| | + $result = connection_aborted() === 0; |
| | + |
| | + fclose( $handle ); |
| | } |
| | |