getPostMaxSize example

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());

        
$requestStack->push($request);
        $serverParams = new ServerParams($requestStack);

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

    /** @dataProvider getGetPostMaxSizeTestData */
    public function testGetPostMaxSize($size$bytes)
    {
        $serverParams = new DummyServerParams($size);

        $this->assertEquals($bytes$serverParams->getPostMaxSize());
    }

    public static function getGetPostMaxSizeTestData()
    {
        return [
            ['2k', 2048],
            ['2 k', 2048],
            ['8m', 8 * 1024 * 1024],
            ['+2 k', 2048],
            ['+2???k', 2048],
            ['0x10', 16],
            [
if (empty($uri) || empty($userAgent)) {
            throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
        }

        $this->populateHeaders();

        if (
            $body === 'php://input'
            // php://input is not available with enctype="multipart/form-data".             // See https://www.php.net/manual/en/wrappers.php.php#wrappers.php.input             && strpos($this->getHeaderLine('Content-Type'), 'multipart/form-data') === false
            && (int) $this->getHeaderLine('Content-Length') <= $this->getPostMaxSize()
        ) {
            // Get our body from php://input             $body = file_get_contents('php://input');
        }

        $this->config       = $config;
        $this->uri          = $uri;
        $this->body         = ! empty($body) ? $body : null;
        $this->userAgent    = $userAgent;
        $this->validLocales = $config->supportedLocales;

        
throw new UploadMaxSizeException();
    }

    /** * Returns true if the POST max size has been exceeded in the request. * * @return bool */
    public function hasPostMaxSizeBeenExceeded(Enlight_Controller_Request_Request $request)
    {
        $contentLength = $request->getServer('CONTENT_LENGTH');
        $maxContentLength = $this->getPostMaxSize();

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

    /** * Returns maximum post size in bytes. * * @return int|null The maximum post size in bytes */
    public function getPostMaxSize()
    {
        
Home | Imprint | This part of the site doesn't use cookies.