!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php54/usr/share/pear/test/HttpFoundation/Symfony/Component/HttpFoundation/Tests/   drwxr-xr-x
Free 293.9 GB of 429.69 GB (68.4%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     BinaryFileResponseTest.php (7.17 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpFoundation\Tests;

use 
Symfony\Component\HttpFoundation\BinaryFileResponse;
use 
Symfony\Component\HttpFoundation\Request;
use 
Symfony\Component\HttpFoundation\ResponseHeaderBag;

class 
BinaryFileResponseTest extends ResponseTestCase
{
    public function 
testConstruction()
    {
        
$response = new BinaryFileResponse('README.md'404, array('X-Header' => 'Foo'), truenulltruetrue);
        
$this->assertEquals(404$response->getStatusCode());
        
$this->assertEquals('Foo'$response->headers->get('X-Header'));
        
$this->assertTrue($response->headers->has('ETag'));
        
$this->assertTrue($response->headers->has('Last-Modified'));
        
$this->assertFalse($response->headers->has('Content-Disposition'));

        
$response BinaryFileResponse::create('README.md'404, array(), trueResponseHeaderBag::DISPOSITION_INLINE);
        
$this->assertEquals(404$response->getStatusCode());
        
$this->assertFalse($response->headers->has('ETag'));
        
$this->assertEquals('inline; filename="README.md"'$response->headers->get('Content-Disposition'));
    }

    
/**
     * @expectedException \LogicException
     */
    
public function testSetContent()
    {
        
$response = new BinaryFileResponse('README.md');
        
$response->setContent('foo');
    }

    public function 
testGetContent()
    {
        
$response = new BinaryFileResponse('README.md');
        
$this->assertFalse($response->getContent());
    }

    
/**
     * @dataProvider provideRanges
     */
    
public function testRequests($requestRange$offset$length$responseRange)
    {
        
$response BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();

        
// do a request to get the ETag
        
$request Request::create('/');
        
$response->prepare($request);
        
$etag $response->headers->get('ETag');

        
// prepare a request for a range of the testing file
        
$request Request::create('/');
        
$request->headers->set('If-Range'$etag);
        
$request->headers->set('Range'$requestRange);

        
$file fopen(__DIR__.'/File/Fixtures/test.gif''r');
        
fseek($file$offset);
        
$data fread($file$length);
        
fclose($file);

        
$this->expectOutputString($data);
        
$response = clone $response;
        
$response->prepare($request);
        
$response->sendContent();

        
$this->assertEquals(206$response->getStatusCode());
        
$this->assertEquals('binary'$response->headers->get('Content-Transfer-Encoding'));
        
$this->assertEquals($responseRange$response->headers->get('Content-Range'));
    }

    public function 
provideRanges()
    {
        return array(
            array(
'bytes=1-4'14'bytes 1-4/35'),
            array(
'bytes=-5'305'bytes 30-34/35'),
            array(
'bytes=30-'305'bytes 30-34/35'),
            array(
'bytes=30-30'301'bytes 30-30/35'),
            array(
'bytes=30-34'305'bytes 30-34/35'),
        );
    }

    
/**
     * @dataProvider provideFullFileRanges
     */
    
public function testFullFileRequests($requestRange)
    {
        
$response BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();

        
// prepare a request for a range of the testing file
        
$request Request::create('/');
        
$request->headers->set('Range'$requestRange);

        
$file fopen(__DIR__.'/File/Fixtures/test.gif''r');
        
$data fread($file35);
        
fclose($file);

        
$this->expectOutputString($data);
        
$response = clone $response;
        
$response->prepare($request);
        
$response->sendContent();

        
$this->assertEquals(200$response->getStatusCode());
        
$this->assertEquals('binary'$response->headers->get('Content-Transfer-Encoding'));
    }

    public function 
provideFullFileRanges()
    {
        return array(
            array(
'bytes=0-'),
            array(
'bytes=0-34'),
            array(
'bytes=-35'),
            
// Syntactical invalid range-request should also return the full resource
            
array('bytes=20-10'),
            array(
'bytes=50-40'),
        );
    }

    
/**
     * @dataProvider provideInvalidRanges
     */
    
public function testInvalidRequests($requestRange)
    {
        
$response BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();

        
// prepare a request for a range of the testing file
        
$request Request::create('/');
        
$request->headers->set('Range'$requestRange);

        
$response = clone $response;
        
$response->prepare($request);
        
$response->sendContent();

        
$this->assertEquals(416$response->getStatusCode());
        
$this->assertEquals('binary'$response->headers->get('Content-Transfer-Encoding'));
        
#$this->assertEquals('', $response->headers->get('Content-Range'));
    
}

    public function 
provideInvalidRanges()
    {
        return array(
            array(
'bytes=-40'),
            array(
'bytes=30-40')
        );
    }

    public function 
testXSendfile()
    {
        
$request Request::create('/');
        
$request->headers->set('X-Sendfile-Type''X-Sendfile');

        
BinaryFileResponse::trustXSendfileTypeHeader();
        
$response BinaryFileResponse::create('README.md');
        
$response->prepare($request);

        
$this->expectOutputString('');
        
$response->sendContent();

        
$this->assertContains('README.md'$response->headers->get('X-Sendfile'));
    }

    
/**
     * @dataProvider getSampleXAccelMappings
     */
    
public function testXAccelMapping($realpath$mapping$virtual)
    {
        
$request Request::create('/');
        
$request->headers->set('X-Sendfile-Type''X-Accel-Redirect');
        
$request->headers->set('X-Accel-Mapping'$mapping);

        
$file $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
                     ->
disableOriginalConstructor()
                     ->
getMock();
        
$file->expects($this->any())
             ->
method('getRealPath')
             ->
will($this->returnValue($realpath));
        
$file->expects($this->any())
             ->
method('isReadable')
             ->
will($this->returnValue(true));

        
BinaryFileResponse::trustXSendFileTypeHeader();
        
$response = new BinaryFileResponse('README.md');
        
$reflection = new \ReflectionObject($response);
        
$property $reflection->getProperty('file');
        
$property->setAccessible(true);
        
$property->setValue($response$file);

        
$response->prepare($request);
        
$this->assertEquals($virtual$response->headers->get('X-Accel-Redirect'));
    }

    public function 
getSampleXAccelMappings()
    {
        return array(
            array(
'/var/www/var/www/files/foo.txt''/files/=/var/www/''/files/var/www/files/foo.txt'),
            array(
'/home/foo/bar.txt''/files/=/var/www/,/baz/=/home/foo/''/baz/bar.txt'),
        );
    }

    protected function 
provideResponse()
    {
        return new 
BinaryFileResponse('README.md');
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0969 ]--