protected function setHeaders(array $headers = array()) {
        if(count($headers) === 0) {
            return;
        }
        $this->headers = array_merge($this->headers, $headers);

        $curl_headers = [];

        $curl_version = curl_version();

        foreach ($this->headers as $key => $value) {
            $curl_headers[] = $key.': '.$value;
        }

        // add some helpful information about environment
        $server_info = array(
            'curl_version' => (isset($curl_version['version']) ? $curl_version['version'] : null),
            'php_version' => phpversion(),
            'php_sapi' => php_sapi_name()
        );
        $curl_headers[] = 'X-Server-Lang: PHP';
        $curl_headers[] = 'X-Server-Lang-Info: ' . base64_encode(json_encode($server_info));
        $curl_headers[] = 'X-Server-Software: '. (!empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null);
        $curl_headers[] = 'X-Server-Protocol: '. (!empty($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null);
        curl_setopt($this->request, CURLOPT_HTTPHEADER, $curl_headers);
    }
protected function setHeaders(array $headers = array()) {
        if(count($headers) === 0) {
            return;
        }
        $this->headers = array_merge($this->headers, $headers);

        $curl_headers = [];

        $curl_version = curl_version();

        foreach ($this->headers as $key => $value) {
            $curl_headers[] = $key.': '.$value;
        }

        // add some helpful information about environment
        $server_info = array(
            'curl_version' => (isset($curl_version['version']) ? $curl_version['version'] : null),
            'php_version' => phpversion(),
            'php_sapi' => php_sapi_name()
        );
        $curl_headers[] = 'X-Server-Lang: PHP';
        $curl_headers[] = 'X-Server-Lang-Info: ' . base64_encode(json_encode($server_info));
        $curl_headers[] = 'X-Server-Software: '. (!empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null);
        $curl_headers[] = 'X-Server-Protocol: '. (!empty($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null);
        curl_setopt($this->request, CURLOPT_HTTPHEADER, $curl_headers);
    }
protected function setHeaders ( array $ headers = array ( ) ) { if ( count ( $ headers ) === 0 ) { return ; } $ this -> headers = array_merge ( $ this -> headers , $ headers ) ; $ curl_headers = [ ] ; $ curl_version = curl_version ( ) ; foreach ( $ this -> headers as $ key => $ value ) { $ curl_headers [ ] = $ key . ': ' . $ value ; } // add some helpful information about environment $ server_info = array ( 'curl_version' => ( isset ( $ curl_version [ 'version' ] ) ? $ curl_version [ 'version' ] : null ) , 'php_version' => phpversion ( ) , 'php_sapi' => php_sapi_name ( ) ) ; $ curl_headers [ ] = 'X-Server-Lang: PHP' ; $ curl_headers [ ] = 'X-Server-Lang-Info: ' . base64_encode ( json_encode ( $ server_info ) ) ; $ curl_headers [ ] = 'X-Server-Software: ' . ( ! empty ( $ _SERVER [ 'SERVER_SOFTWARE' ] ) ? $ _SERVER [ 'SERVER_SOFTWARE' ] : null ) ; $ curl_headers [ ] = 'X-Server-Protocol: ' . ( ! empty ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : null ) ; curl_setopt ( $ this -> request , CURLOPT_HTTPHEADER , $ curl_headers ) ; }
Adds headers to the current request
@param array $headers
Adds headers to the current request