Get key-value array

@see https://stackoverflow.com/questions/9183178/can-php-curl-retrieve-response-headers-and-body-in-a-single-request

@param $header

@return array|null
321994
protected function dispatchHeaderValue($header)
    {
        $header = explode(':', $header, 2);

        if (count($header) < 2) {
            return null;
        }

        return array(
            'name' => trim($header[0]),
            'value' => trim($header[1]),
        );
    }
108120
public function getHeader($header, $first = true)
    {
        $normalizedHeader = str_replace('-', '_', strtolower($header));
        foreach ($this->headers as $key => $value) {
            if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
                if ($first) {
                    return is_array($value) ? (count($value) ? $value[0] : '') : $value;
                }

                return is_array($value) ? $value : array($value);
            }
        }

        return $first ? null : array();
    }
1082503
public function getHeader($key)
    {
        $key = str_replace('-', '_', strtoupper($key));

        if ($this->hasHeader($key)) {
            return $_SERVER[$key];
        }

        if ($this->hasHeader('HTTP_'.$key)) {
            return $_SERVER['HTTP_'.$key];
        }

        return null;
    }
967756
public function getHeader(string $key) {
		// return the header of null if missing
		return isset($this->response['headers'][$key]) ? 
			$this->response['headers'][$key] : null;
	}
1281279
public function setHeader($header)
    {
        $headers = [];

        if (is_array($header)) {
            foreach ($header as $key => $value) {
                $headers[] = $key . ': ' . $value;
            }
        } else {
            $headers[] = $header;
        }

        $this->setOpt(CURLOPT_HTTPHEADER, $headers);

        return $this;
    }
816182
private function parseQualityValues(string $header) : array
    {
        $values = $this->parseHeaderParameters($header);

        $result = [];

        $count = count($values);
        $position = $count - 1;

        foreach ($values as $value => $parameters) {
            $parameters = array_change_key_case($parameters, CASE_LOWER);

            if (isset($parameters['q'])) {
                if (preg_match('/^((?:0\.?[0-9]{0,3})|(?:1\.?0{0,3}))$/', $parameters['q']) === 0) {
                    continue;
                }

                $quality = (float) $parameters['q'];
            } else {
                $quality = 1.0;
            }

            $weight = $position + $count * (int) ($quality * 1000.0);

            $result[] = [$value, $quality, $weight];

            $position--;
        }

        usort($result, static function(array $a, array $b) {
            return $b[2] - $a[2];
        });

        $values = [];

        foreach ($result as $value) {
            $values[$value[0]] = $value[1];
        }

        return $values;
    }
595609
public function splitHttpAcceptHeader($header)
    {
        $values = [];
        foreach (array_filter(explode(',', $header)) as $value) {
            // Cut off any q-value that might come after a semi-colon
            if ($pos = strpos($value, ';')) {
                $q = (float) trim(substr($value, strpos($value, '=') + 1));
                $value = substr($value, 0, $pos);
            } else {
                $q = 1;
            }

            if (0 < $q) {
                $values[trim($value)] = $q;
            }
        }

        arsort($values);

        return array_keys($values);
    }
748056
public function getHeader($key)
	{
		$key = strtolower($key);

		return isset($this->headers[$key]) ? $this->headers[$key] : null;
	}
1335544
public function getHeader($header)
    {
        $response = $this->getResponse();

        return $response->hasHeader($header) ? $response->getHeader($header)[0] : null;
    }
1027118
protected function prepareRequestHeader(Header $header): array
    {
        $result = [];
        foreach ($header as $name => $value) {
            $result[] = $name . ': ' . $value;
        }
        return $result;
    }
1178846
private function parseHeader($header) {
        if(!empty($header)) {
            $pos = strpos($header, ": ");

            if(false !== $pos) {
                $name = substr($header,0,$pos);
                $value = substr($header,$pos+2);

                $this->headers[$name] = $value;
            }
        }
    }
669865
public static function getHTTPStatusCode($header)
  {
    $first_line = strtok($header, "\n");
    
    preg_match("# [0-9]{3}#", $first_line, $match);
    
    if (isset($match[0]))
      return (int)trim($match[0]);
    else
      return null;
  }
568964
public static function getHeader($header) {

		$headers = static :: getHeaders();

		if(true === isset($headers[$header])) {
			return $headers[$header];
		}

		return null;
	}
1218141
public function headers(): array
    {
        return collect($this->request->getHeaders())->mapWithKeys(function ($values, $header) {
            return [$header => $values[0]];
        })->all();
    }
1323339
public function getRequestInfo($key = null)
    {
        if ( ! $this->isInitialized())
        {
            return $key ? '' : [];
        }

        return $key ? curl_getinfo($this->curl, $key) : curl_getinfo($this->curl);
    }
1339468
public function get($header = null) {

        if (is_null($header)) {
            return $this->headers;
        }

        $index = $this->getIndexCaseInsensitive($header);

        return $index === null ? null : $this->headers[$index];

    }
468173
public function getResponseHeader($header)
        {
            if (! isset($this->responseHeaders[$header])) {
                throw new \InvalidArgumentException('Header does not exist');
            }

            return $this->responseHeaders[$header];
        }