Вход Регистрация
Файл: gapps/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyPostSize.php
Строк: 43
<?php

namespace IlluminateFoundationHttpMiddleware;

use 
Closure;
use 
IlluminateHttpExceptionPostTooLargeException;

class 
VerifyPostSize
{
    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     *
     * @throws IlluminateHttpExceptionPostTooLargeException
     */
    
public function handle($requestClosure $next)
    {
        if (
$request->server('CONTENT_LENGTH') > $this->getPostMaxSize()) {
            throw new 
PostTooLargeException;
        }

        return 
$next($request);
    }

    
/**
     * Determine the server 'post_max_size' as bytes.
     *
     * @return int
     */
    
protected function getPostMaxSize()
    {
        if (
is_numeric($postMaxSize ini_get('post_max_size'))) {
            return (int) 
$postMaxSize;
        }

        
$metric strtoupper(substr($postMaxSize, -1));

        switch (
$metric) {
            case 
'K':
                return (int) 
$postMaxSize 1024;
            case 
'M':
                return (int) 
$postMaxSize 1048576;
            case 
'G':
                return (int) 
$postMaxSize 1073741824;
            default:
                return (int) 
$postMaxSize;
        }
    }
}
Онлайн: 1
Реклама