<commit_before><?php

/*
 * This file is part of the Orient package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * This class wraps an HTTP response to easily manage some HTTP headers and
 * the body.
 *
 * @package    
 * @subpackage 
 * @author     <NAME> <<EMAIL>>
 */

namespace Orient\Http;

class Response
{
    protected $headers;
    protected $raw_headers;
    protected $status_code;
    protected $body;
    protected $response;

    /**
     * Constructs a new object from an existing HTTP response.
     *
     * @param String $response
     */
    public function __construct($response)
    {
        list($this->raw_headers, $this->body) = explode("\r\n\r\n", $response, 2);

        $this->headers = $this->buildHeaders($this->raw_headers);
    }

    public function __toString()
    {
        return $this->getResponse();
    }

    /**
     * Returns the body of the response.
     *
     * @return String
     */
    public function getBody()
    {
        return $this->body;
    }

    /**
     * Returns the whole response.
     *
     * @return String
     */
    public function getResponse()
    {
        return $this->getRawHeaders() . $this->getBody();
    }

    /**
     * Returns the status code of the response.
     *
     * @return String
     */
    public function getStatusCode()
    {
        return $this->status_code;
    }

    /**
     * Builds headers array from a well-formatted string.
     *
     * @param String $headers
     */
    protected function buildHeaders($headers)
    {
        $parts = explode("\r\n", $headers);

        $this->status_code = $parts[0];
        unset($parts[0]);

        foreach ($parts as $header) {
            $header = explode(':', $header);
            $this->headers[$header[0]] = $header[1];
        }
    }

    /**
     * Returns all the headers as a string.
     *
     * @return String
     */
    protected function getRawHeaders()
    {
        return $this->raw_headers;
    }
}
<commit_msg>Fix wrong assignment that resulted in the parsed headers being inadvertently overwritten.<commit_after><?php

/*
 * This file is part of the Orient package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * This class wraps an HTTP response to easily manage some HTTP headers and
 * the body.
 *
 * @package    
 * @subpackage 
 * @author     <NAME> <<EMAIL>>
 */

namespace Orient\Http;

class Response
{
    protected $headers;
    protected $raw_headers;
    protected $status_code;
    protected $body;
    protected $response;

    /**
     * Constructs a new object from an existing HTTP response.
     *
     * @param String $response
     */
    public function __construct($response)
    {
        list($this->raw_headers, $this->body) = explode("\r\n\r\n", $response, 2);

        $this->buildHeaders($this->raw_headers);
    }

    public function __toString()
    {
        return $this->getResponse();
    }

    /**
     * Returns the body of the response.
     *
     * @return String
     */
    public function getBody()
    {
        return $this->body;
    }

    /**
     * Returns the whole response.
     *
     * @return String
     */
    public function getResponse()
    {
        return $this->getRawHeaders() . $this->getBody();
    }

    /**
     * Returns the status code of the response.
     *
     * @return String
     */
    public function getStatusCode()
    {
        return $this->status_code;
    }

    /**
     * Builds headers array from a well-formatted string.
     *
     * @param String $headers
     */
    protected function buildHeaders($headers)
    {
        $parts = explode("\r\n", $headers);

        $this->status_code = $parts[0];
        unset($parts[0]);

        foreach ($parts as $header) {
            $header = explode(':', $header);
            $this->headers[$header[0]] = $header[1];
        }
    }

    /**
     * Returns all the headers as a string.
     *
     * @return String
     */
    protected function getRawHeaders()
    {
        return $this->raw_headers;
    }
}

{'fraction_non_alphanumeric': 0.12713650199016624, 'fraction_numerical': 0.0023413720440177946, 'mean_word_length': 2.0470756062767475, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 40, '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': '1255415', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1225, 'n_words': 356}