<commit_before><?php
/*!
 * Radium
 * Copyright (C) 2011-2014 <NAME>.
 * https://github.com/nirix
 *
 * This file is part of Radium.
 *
 * Radium is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 only.
 *
 * Radium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Radium. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Radium\Http;

use Radium\Kernel;

/**
 * Radium's HTTP response class.
 *
 * @since 0.2
 * @package Radium/Http
 * @author <NAME>.
 * @copyright (C) <NAME>.
 */
class Response
{
    /**
     * HTTP status code.
     */
    public $status = 200;

    /**
     * Response body.
     */
    public $body;

    public function __construct($response = null)
    {
        // Anonymous function to configure the response block-style.
        if (is_callable($response)) {
            $response($this);
        }
        // String to be used as the body.
        elseif (is_string($response)) {
            $this->body = $response;
        }
    }

    /**
     * Sends the response to the browser.
     */
    public function send()
    {
        // Set response code
        $this->setResponseCode();<commit_msg>Allow setting of response content-type.<commit_after><?php
/*!
 * Radium
 * Copyright (C) 2011-2014 <NAME>.
 * https://github.com/nirix
 *
 * This file is part of Radium.
 *
 * Radium is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 only.
 *
 * Radium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Radium. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Radium\Http;

use Radium\Kernel;

/**
 * Radium's HTTP response class.
 *
 * @since 0.2
 * @package Radium/Http
 * @author <NAME>.
 * @copyright (C) <NAME>.
 */
class Response
{
    /**
     * HTTP status code.
     */
    public $status = 200;

    /**
     * Response body.
     */
    public $body;

    /**
     * Response content-type.
     */
    public $contentType = 'text/html';

    public function __construct($response = null)
    {
        // Anonymous function to configure the response block-style.
        if (is_callable($response)) {
            $response($this);
        }
        // String to be used as the body.
        elseif (is_string($response)) {
            $this->body = $response;
        }
    }

    /**
     * Takes a file extension and sets the content-type.
     *
     * @param string $format
     */
    public function format($format)
    {
        switch ($format) {
            case 'html':
                $this->contentType = 'text/html';
                break;

            case 'json':
                $this->contentType = 'application/json';
                break;
        }
    }

    /**
     * Sends the response to the browser.
     */
    public function send()
    {
        // Set response code
        $this->setResponseCode();

        // Set content-type
        header("Content-Type: {$this->contentType}");
{'fraction_non_alphanumeric': 0.11096039066739012, 'fraction_numerical': 0.007596310363537711, 'mean_word_length': 2.156678082191781, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1499386', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1010, 'n_words': 376}