<commit_before><?php

namespace App\Http\Middleware;

use function App\env_production;
use Closure;
use Illuminate\Config\Repository as Config;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
 * Class CorsHeaders.
 *
 * @package App\Http\Middleware
 */
class CorsHeaders
{
    /**
     * @var Config
     */
    private $config;

    /**
     * @var ResponseFactory
     */
    private $responseFactory;

    /**
     * CorsHeaders constructor.
     *
     * @param Config $config
     * @param ResponseFactory $responseFactory
     */
    public function __construct(Config $config, ResponseFactory $responseFactory)
    {
        $this->config = $config;
        $this->responseFactory = $responseFactory;
    }

    /**
     * Handle an incoming request.
     *
     * @param Request $request
     * @param Closure $next
     * @return Response
     */
    public function handle($request, Closure $next)
    {
        $this->assertOriginHeader($request);

        $response = $request->getMethod() === 'OPTIONS'
            ? $this->responseFactory->make()
            : $next($request);

        $this->addCorsHeaders($request, $response);

        return $response;
    }

    /**
     * Assert the origin header value.
     *
     * @param Request $request
     */
    private function assertOriginHeader($request): void
    {
        if (env_production() && !$this->isAllowedOrigin($request->header('origin'))) {
            throw new HttpException(Response::HTTP_NOT_ACCEPTABLE);
        }
    }

    /**
     * Determine if the origin value is allowed.<commit_msg>Removed origin check<commit_after><?php

namespace App\Http\Middleware;

use function App\env_production;
use Closure;
use Illuminate\Config\Repository as Config;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
 * Class CorsHeaders.
 *
 * @package App\Http\Middleware
 */
class CorsHeaders
{
    /**
     * @var Config
     */
    private $config;

    /**
     * @var ResponseFactory
     */
    private $responseFactory;

    /**
     * CorsHeaders constructor.
     *
     * @param Config $config
     * @param ResponseFactory $responseFactory
     */
    public function __construct(Config $config, ResponseFactory $responseFactory)
    {
        $this->config = $config;
        $this->responseFactory = $responseFactory;
    }

    /**
     * Handle an incoming request.
     *
     * @param Request $request
     * @param Closure $next
     * @return Response
     */
    public function handle($request, Closure $next)
    {
//        $this->assertOriginHeader($request);

        $response = $request->getMethod() === 'OPTIONS'
            ? $this->responseFactory->make()
            : $next($request);

        $this->addCorsHeaders($request, $response);

        return $response;
    }

    /**
     * Assert the origin header value.
     *
     * @param Request $request
     */
    private function assertOriginHeader($request): void
    {
        if (env_production() && !$this->isAllowedOrigin($request->header('origin'))) {
            throw new HttpException(Response::HTTP_NOT_ACCEPTABLE);
        }
    }

    /**
     * Determine if the origin value is allowed.
{'fraction_non_alphanumeric': 0.12276064610866373, 'fraction_numerical': 0.0, 'mean_word_length': 2.544224765868887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5004141', 'n_tokens_mistral': 952, 'n_tokens_neox': 947, 'n_words': 209}