<commit_before><?php

class FeedsController extends Zend_Controller_Action
{
    public function stationRssAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        if ((Application_Model_Preference::getStationPodcastPrivacy()
                && $this->getRequest()->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
                && !RestAuth::verifyAuth(true, false, $this)) {
            $this->getResponse()
                ->setHttpResponseCode(401);
            return;
        }


        $rssData = Application_Service_PodcastService::createStationRssFeed();

        $mimeType = "text/xml";
        header("Content-Type: $mimeType; charset=UTF-8");

        if (isset($_SERVER['HTTP_RANGE'])) {
            header('HTTP/1.1 206 Partial Content');
        } else {
            header('HTTP/1.1 200 OK');
        }
        header("Content-Type: $mimeType");
        header("Content-Transfer-Encoding: binary");
        header('Cache-Control: public, must-revalidate, max-age=0');
        header('Pragma: no-cache');
        header('Accept-Ranges: bytes');
        $size = strlen($rssData);

        $begin = 0;
        $end   = $size - 1;

        //ob_start(); //Must start a buffer here for these header() functions

        if (isset($_SERVER['HTTP_RANGE'])) {
            if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
                $begin = intval($matches[1]);
                if (!empty($matches[2])) {
                    $end = intval($matches[2]);
                }
            }<commit_msg>Add CORS handling to podcast feed<commit_after><?php

class FeedsController extends Zend_Controller_Action
{
    public function stationRssAction()
    {
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $request = $this->getRequest();
        $response = $this->getResponse();

        if ((Application_Model_Preference::getStationPodcastPrivacy()
                && $request->getParam("sharing_token") != Application_Model_Preference::getStationPodcastDownloadKey())
                && !RestAuth::verifyAuth(true, false, $this)) {
            $response->setHttpResponseCode(401);
            return;
        }

        CORSHelper::enableCrossOriginRequests($request, $response);

        $rssData = Application_Service_PodcastService::createStationRssFeed();

        $mimeType = "text/xml";
        header("Content-Type: $mimeType; charset=UTF-8");

        if (isset($_SERVER['HTTP_RANGE'])) {
            header('HTTP/1.1 206 Partial Content');
        } else {
            header('HTTP/1.1 200 OK');
        }
        header("Content-Type: $mimeType");
        header("Content-Transfer-Encoding: binary");
        header('Cache-Control: public, must-revalidate, max-age=0');
        header('Pragma: no-cache');
        header('Accept-Ranges: bytes');
        $size = strlen($rssData);

        $begin = 0;
        $end   = $size - 1;

        //ob_start(); //Must start a buffer here for these header() functions

        if (isset($_SERVER['HTTP_RANGE'])) {
            if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
                $begin = intval($matches[1]);
                if (!empty($matches[2])) {
                    $end = intval($matches[2]);
                }
            }
{'fraction_non_alphanumeric': 0.16020821283979178, 'fraction_numerical': 0.01156737998843262, 'mean_word_length': 2.3452611218568666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7245723', 'n_tokens_mistral': 1010, 'n_tokens_neox': 956, 'n_words': 166}