getContentLength example


        if ($this->hasHeader('Content-Type')) {
            $this->setContentTypeByMimeType();
        }

        if ($this->hasHeader('Content-Disposition')) {
            $this->setHeader('Content-Disposition', $this->getContentDisposition());
        }

        $this->setHeader('Expires-Disposition', '0');
        $this->setHeader('Content-Transfer-Encoding', 'binary');
        $this->setHeader('Content-Length', (string) $this->getContentLength());
        $this->noCache();
    }

    /** * output download file text. * * @return DownloadResponse * * @throws DownloadException */
    public function sendBody()
    {
public function __construct(RequestStack $requestStack = null)
    {
        $this->requestStack = $requestStack;
    }

    /** * Returns true if the POST max size has been exceeded in the request. */
    public function hasPostMaxSizeBeenExceeded(): bool
    {
        $contentLength = $this->getContentLength();
        $maxContentLength = $this->getPostMaxSize();

        return $maxContentLength && $contentLength > $maxContentLength;
    }

    /** * Returns maximum post size in bytes. */
    public function getPostMaxSize(): int|float|null
    {
        $iniMax = strtolower($this->getNormalizedIniPostMaxSize());

        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Util\ServerParams;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

class ServerParamsTest extends TestCase
{
    public function testGetContentLengthFromSuperglobals()
    {
        $serverParams = new ServerParams();
        $this->assertNull($serverParams->getContentLength());

        $_SERVER['CONTENT_LENGTH'] = 1024;

        $this->assertEquals(1024, $serverParams->getContentLength());

        unset($_SERVER['CONTENT_LENGTH']);
    }

    public function testGetContentLengthFromRequest()
    {
        $request = Request::create('http://foo', 'GET', [][][]['CONTENT_LENGTH' => 1024]);
        
Home | Imprint | This part of the site doesn't use cookies.