Determine the version number of the API this dataset is using

@param  array  $responseHeaders An array with the cURL headers received

@return double The Socrata API version number this dataset uses
550803
private function parseApiVersion ($responseHeaders)
    {
        // A header that's unique to the legacy API
        if (array_key_exists('X-SODA2-Legacy-Types', $responseHeaders) && $responseHeaders['X-SODA2-Legacy-Types'])
        {
            return 1;
        }

        // A header that's unique to the new API
        if (array_key_exists('X-SODA2-Truth-Last-Modified', $responseHeaders))
        {
            if (empty($this->metadata))
            {
                $this->getMetadata();
            }

            if ($this->metadata['newBackend'])
            {
                return 2.1;
            }

            return 2;
        }

        return 0;
    }
136837
public function parseReturnHeaders($headers)
    {
        $head = [];
        foreach ($headers as $k => $v) {
            $t = explode(':', $v, 2);
            if (isset($t[1])) {
                $head[trim($t[0])] = trim($t[1]);
            } else {
                $head[] = $v;
                if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) {
                    $head['reponse_code'] = intval($out[1]);
                }
            }
        }
        $this->debug->debug(__FUNCTION__, 'Response Header: ', $head);

        return $head;
    }
914903
private function getProtocolVersion(string $requestVersion): int
    {
        switch ($requestVersion) {
            case '1.0':
                return CURL_HTTP_VERSION_1_0;
            case '1.1':
                return CURL_HTTP_VERSION_1_1;
            case '2.0':
                if (defined('CURL_HTTP_VERSION_2_0')) {
                    return CURL_HTTP_VERSION_2_0;
                }
                throw new \UnexpectedValueException('libcurl 7.33 needed for HTTP 2.0 support');
        }

        return CURL_HTTP_VERSION_NONE;
    }
568914
private function _extractHttpStatusCode($headers){
    	$statusCode = null; 
        if (1 === preg_match("/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/", $headers, $matches)) {
        	//The matches array [entireMatchString, protocol, statusCode, the rest]
            $statusCode = $matches[2]; 
        }
        return $statusCode;
    }
243033
protected function _getHttpStatusFromHeaders($headers)
  {
    $httpstatus = '500';
    $match      = [];
    if (!empty($headers[0]) && preg_match('/HTTP\/\d\.\d (\d{3})/', $headers[0], $match)) {
      $httpstatus = $match[1];
    }
    return $httpstatus;
  }
1309466
protected function headers($headers)
    {
        $headers = collect($headers)->map(function ($header) {
            return $header[0];
        })->toArray();

        return $this->hideParameters($headers,
            Telescope::$hiddenRequestHeaders
        );
    }
692563
protected function _parseResponseHeaders($headers)
    {
        $headers = str_replace("\r", "", $headers);
        $headers = explode("\n", $headers);
        $parsed  = array();

        foreach($headers as $header)
        {
            $field_end = strpos($header, ':');

            if($field_end === FALSE)
            {
                /* Cover the case where we're at the first header, the HTTP
                 *  status header
                 */
                $field = 'status';
                $value = $header;
            }
            else
            {
                $field = substr($header, 0, $field_end);
                $value = substr($header, $field_end + 1);
            }

            $parsed[$field] = $value;
        }

        return $parsed;
    }
175856
public static function formatHeadersForCurl(array $headers)
    {
        $curlHeaders = array();

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

        return $curlHeaders;
    }
1073897
protected function _getRateLimitInfo($headers)
  {
    if (! isset($headers['x-rate-limit-limit'])) {
      return null;
    }
    $rate = [
      'limit'     => $headers['x-rate-limit-limit'],
      'remaining' => $headers['x-rate-limit-remaining'],
      'reset'     => $headers['x-rate-limit-reset']
    ];
    if ($this->_return_format === CODEBIRD_RETURNFORMAT_OBJECT) {
      return (object) $rate;
    }
    return $rate;
  }
629626
private function getCurloptHttpVersion(RequestInterface $Request) : int
    {
        switch($Request->getProtocolVersion()){
            case '1.0':
                return CURL_HTTP_VERSION_1_0;
            case '1.1':
                return CURL_HTTP_VERSION_1_1;
            case '2.0':
                return CURL_HTTP_VERSION_2_0;
        }
        return CURL_HTTP_VERSION_NONE;
    }
549955
protected function responseWithHeaders($response)
    {
        foreach ($this->getHeaders() as $key => $value) {
            $response->headers->set($key, $value);
        }

        return $response;
    }
616143
protected function configureHeaders(array $headers){
        $configuredHeaders = array();
        foreach($headers as $header => $value){
            $configuredHeaders[] = "$header: $value";
        }
        return $this->addCurlOption(CURLOPT_HTTPHEADER, $configuredHeaders);
    }
428248
protected function _determineVersion(): int
    {
        // if extensions are present
        if (count($this->_extensions)) {
            return self::VERSION_3;
        }
        // if UniqueIdentifier is present
        if (isset($this->_issuerUniqueID) || isset($this->_subjectUniqueID)) {
            return self::VERSION_2;
        }
        return self::VERSION_1;
    }
707086
public function sendHeaders(Response $response)
    {
        if (headers_sent()) {
            return $response;
        }

        $statusCode = $response->getStatusCode();
        $protocolVersion = $response->getProtocolVersion();
        $statusText = $response->getReasonPhrase();
        foreach ($response->headers->allPreserveCase() as $name => $values) {
            foreach ($values as $value) {
                header($name.': '.$value, false, $statusCode);
            }
        }
        $statusHeader = sprintf('HTTP/%s %s %s', $protocolVersion, $statusCode, $statusText);
        header($statusHeader, true, $statusCode);

        return $response;
    }
1353186
private function normalizeHeaders(array $headers)
    {
        $ignoreHeaders = $this->ignoreHeaders;

        foreach ($ignoreHeaders as $ignoreHeader) {
            $headers = array_filter($headers, function($header) use ($ignoreHeader) {
                return stripos($header, $ignoreHeader.':') !== 0;
            });
        }

        return $headers;
    }
973700
public function getHttpResponse(array $headers = [])
    {
        $client = new Client();
        $urls = $this->getUrl();

        return $client->request('GET', $urls[0], ['stream' => true, 'headers' => $headers]);
    }
692661
protected function getRequestHeaders(array $headers)
    {
        $requestHeaders = '';

        foreach ($this->headers as $name => $value) {
            if (!isset($headers[$name])) {
                $requestHeaders .= "$name: $value\r\n";
            }
        }

        foreach ($headers as $name => $value) {
            if (is_numeric($name)) {
                throw new RuntimeException("Invalid HTTP header name $name");
            }

            $requestHeaders .= "$name: $value\r\n";
        }

        return $requestHeaders;
    }