<commit_before><?php
namespace PSFS\base\types\helpers;

use PSFS\base\config\Config;
use PSFS\base\Logger;
use PSFS\base\Request;

class RequestHelper
{
    /**
     * Check CROS requests
     */
    public static function checkCORS()
    {
        Logger::log('Checking CORS');
        $corsEnabled = Config::getInstance()->get('cors.enabled');
        $request = Request::getInstance();
        if (NULL !== $corsEnabled) {
            if ($corsEnabled === '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) {
                if (!headers_sent()) {
                    // TODO include this headers in Template class output method
                    header("Access-Control-Allow-Credentials: true");
                    header("Access-Control-Allow-Origin: *");
                    header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
                    header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-API-SEC-TOKEN, X-API-USER-TOKEN");
                }
                if (Request::getInstance()->getMethod() == 'OPTIONS') {
                    Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests');
                    header("HTTP/1.1 200 OK");
                    exit();
                }
            }
        }
    }
}<commit_msg>FIxed CORS headers<commit_after><?php
namespace PSFS\base\types\helpers;

use PSFS\base\config\Config;
use PSFS\base\Logger;
use PSFS\base\Request;

class RequestHelper
{
    /**
     * Check CROS requests
     */
    public static function checkCORS()
    {
        Logger::log('Checking CORS');
        $corsEnabled = Config::getInstance()->get('cors.enabled');
        $request = Request::getInstance();
        if (NULL !== $corsEnabled) {
            if ($corsEnabled === '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) {
                if (!headers_sent()) {
                    // TODO include this headers in Template class output method
                    header("Access-Control-Allow-Credentials: true");
                    header("Access-Control-Allow-Origin: *");
                    header("Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS");
                    header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-API-SEC-TOKEN, X-API-USER-TOKEN, api_key");
                }
                if (Request::getInstance()->getMethod() == 'OPTIONS') {
                    Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests');
                    header("HTTP/1.1 200 OK");
                    exit();
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.13802528185855825, 'fraction_numerical': 0.0034164673727365906, 'mean_word_length': 2.1182108626198084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '660257', 'n_tokens_mistral': 809, 'n_tokens_neox': 777, 'n_words': 160}