<commit_before><?php

namespace Productsup\Http;
use Productsup\Client as Client;

class Request
{
    const METHOD_POST = 'POST';
    const METHOD_GET = 'GET';
    const METHOD_DELETE = 'DELETE';
    const METHOD_PUT = 'PUT';

    public $method = self::METHOD_GET;
    public $url;
    public $postBody;
    private $headers = array();

    private $_Client;

    /**
     * @param \Productsup\Client A client object
     */
    public function __construct(Client $Client) {
        $this->_Client = $Client;
        $this->headers['X-Auth-Token'] = $this->_Client->getToken();
        $this->headers['Accept'] = 'application/json';
    }

    /**
     *
     * @return string UserAgent for HTTP Request
     */
    public function getUserAgent()
    {
        return 'Productsup API Client (PHP)';
    }

    public function getBody() {
        $body = null;
        if($this->hasData()) {
            return $this->encodeData();
        }
        return $body;
    }

    public function hasData() {
        return $this->postBody && is_array($this->postBody);
    }

    protected function encodeData() {
        return json_encode($this->postBody);
    }

    public function setHeader($name, $value) {
        $this->headers[$name] = $value;
    }


    public function getHeaders() {
        if($this->hasData()) {
            $this->setHeader('Content-Type','application/json');
        }

        $headers = array();
        if(!empty($this->headers)) {
            foreach($this->headers as $key => $value) {
                $headers[] = $key.': '.$value;
            }
        }
        return $headers;
    }
<commit_msg>zip upload if possible<commit_after><?php

namespace Productsup\Http;
use Productsup\Client as Client;

class Request
{
    const METHOD_POST = 'POST';
    const METHOD_GET = 'GET';
    const METHOD_DELETE = 'DELETE';
    const METHOD_PUT = 'PUT';

    public $method = self::METHOD_GET;
    public $url;
    public $postBody;
    private $headers = array();

    private $_Client;

    /**
     * @param \Productsup\Client A client object
     */
    public function __construct(Client $Client) {
        $this->_Client = $Client;
        $this->headers['X-Auth-Token'] = $this->_Client->getToken();
        $this->headers['Accept'] = 'application/json';
    }

    /**
     *
     * @return string UserAgent for HTTP Request
     */
    public function getUserAgent()
    {
        return 'Productsup API Client (PHP)';
    }

    public function getBody() {
        $body = null;
        if($this->hasData()) {
            return $this->encodeData();
        }
        return $body;
    }

    public function hasData() {
        return $this->postBody && is_array($this->postBody);
    }

    protected function encodeData() {
        $encoded = json_encode($this->postBody);
        if(function_exists('gzdeflate')) {
            $encoded = gzdeflate($encoded, 9);
            $this->setHeader('Content-Encoding','gzip');
        }
        return $encoded;
    }

    public function setHeader($name, $value) {
        $this->headers[$name] = $value;
    }


    public function getHeaders() {
        if($this->hasData()) {
            $this->setHeader('Content-Type','application/json');

        }

        $headers = array();
        if(!empty($this->headers)) {
            foreach($this->headers as $key => $value) {
                $headers[] = $key.': '.$value;
            }
        }
        return $headers;
    }

{'fraction_non_alphanumeric': 0.14751732101616627, 'fraction_numerical': 0.0002886836027713626, 'mean_word_length': 2.116007194244604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '5978452', 'n_tokens_mistral': 1031, 'n_tokens_neox': 990, 'n_words': 222}