| | private $hash; |
| | |
| | - public function __construct( $git, $hash ){ |
| | + public function __construct( $git, $hash ) { |
| | $this->git = $git; |
| | $this->hash = $hash; |
| | } |
| | |
| | - public function render(){ |
| | + public function render() { |
| | $filename = $_GET['name'] ?? 'file'; |
| | $buffer = ''; |
| | |
| | $size = $this->git->getObjectSize( $this->hash ); |
| | |
| | - $this->git->stream( $this->hash, function( $d ) use ( &$buffer ){ |
| | - if( strlen( $buffer ) < 12 ){ |
| | + $this->git->stream( $this->hash, function( $d ) use ( &$buffer ) { |
| | + if( strlen( $buffer ) < 12 ) { |
| | $buffer .= $d; |
| | } |
| | } ); |
| | |
| | $mediaType = MediaTypeSniffer::isMediaType( $buffer, $filename ); |
| | |
| | - if( ob_get_level() ){ |
| | + if( ob_get_level() ) { |
| | ob_end_clean(); |
| | } |
| | |
| | header( "Content-Type: " . $mediaType ); |
| | header( "Content-Length: " . $size ); |
| | header( "Content-Disposition: inline; filename=\"" . addslashes( $filename ) . "\"" ); |
| | |
| | - $this->git->stream( $this->hash, function( $d ){ |
| | + $this->git->stream( $this->hash, function( $d ) { |
| | echo $d; |
| | } ); |