Init curl headers if not exists
@param array|string $headers Headers to use (if string, use the type)
@return array
161755
protected function recieveHeaders($headers = null)
	{
		$this->resource = $this->defaultResource;
		if(is_string($headers))
		{
			$type = trim(strtolower($headers));
			$headers = $this->useHeadersFromType($type);
		}
		else{
			if(!is_array($headers))
			{
				$headers = $this->useHeadersFromType();
			}
		}
		return $headers;
	}
361876
private function get_headers_from_curl_response($headers)
    {
        $headers = explode("\r\n", $headers);
        array_shift($headers);
        foreach ($headers as $line) {
            if (strstr($line, ': ')) {
                list($key, $value) = explode(': ', $line);
                $result[$key] = $value;
            }
        }
        return $result;
    }
10015
public function setHeaders(array $headers = [])
    {

        $this->headers = ($headers instanceof Headers) ? $headers : new Headers((array)$headers);

        return $this;

    }
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;
    }
870506
public function setHeaders(array $headers)
    {
        $cookies = $this->cookies;

        try {
            parent::setHeaders($headers);
        } catch (\Throwable $e) {
            $this->cookies = $cookies;

            throw $e;
        }
    }
102201
public function load(array $headers = [])
    {
        $data = $this->getApi()->getConfiguration($headers);

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

        return $client->request('GET', $urls[0], ['stream' => true, 'headers' => $headers]);
    }
1152653
private function parseHttpHeaders($headers) {
    $result = [];
    foreach ($headers as $header) {
      $values = explode(':', $header, 2);
      if (count($values) === 2) {
        list($key, $value) = $values;
        $key = trim($key);
        $value = trim($value);
        // Checking with real cURL it only sends a header if the key & the value
        // are set.
        if ($key && $value) {
          $result[$key] = $value;
        }
      }
    }
    return $result;
  }
1182849
protected function mapHeaders(array $headers)
    {
        $mappedHeaders = array();
        foreach ($headers as $headerPair) {
            list($name, $value) = $headerPair;
            $mappedHeaders[strtolower($name)] = $value;
        }

        return $mappedHeaders;
    }
401156
public function setHeaders($headers)
    {
        $this->requireOpenConnection();

        $response = $this->curl(
            'POST',
            '/proxy/' . $this->port . '/headers',
            (object)$headers
        );
    }
1152849
protected function withHeaders(array $headers)
    {
        $this->headers = [];
        foreach ($headers as $key => $value) {
            $this->headers[ strtolower($key) ] = is_array($value)
                ? $value
                : [ $value ];
        }
    }
1098718
private function setRequestHeaders($headers = array()) {
        foreach ($this->headers as $key => $value) {
            $headers[] = $key . ': ' . $value;
        }
        curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
    }
1182217
public function setHeaders($headers)
    {
        if (!empty($this->headers)) {
            $this->headers = array_merge($this->headers, $headers);
        } else {
            $this->headers = $headers;
        }
        $this->headers = array_merge($this->headers, $headers);

        if ($this->client instanceof \swoole_http_client) {
            $this->client->setHeaders($this->headers);
        }
        return $this;
    }
1339310
protected function setHeaders($headers)
    {
        foreach ($headers as $name => $value) {

            //~ Convert to array
            if (!is_array($value)) {
                $value = [$value];
            }

            //~ Clean values
            foreach ($value as $key => $val) {
                $value[$key] = trim($val);
            }

            $this->headersOriginal[$name]     = $value;
            $this->headers[strtolower($name)] = $value;
        }

        return $this;
    }
1166750
public function setHeaders(array $headers)
	{
		foreach ($headers as $key => $header) {
			$this->setHeader($key, $header);
		}

		return $this;
	}
1194376
private function determineHeaderStringForSignedResponse(array $headers)
    {
        $signedDataHeaders = [];
        ksort($headers);

        foreach ($headers as $headerName => $headerValue) {
            // All headers with the prefix 'X-Bunq-' except 'Server-Signature' need to be signed.
            $headerName = $this->ensureHeaderIsCorrectlyCased($headerName);

            if ($headerName === self::HEADER_SERVER_SIGNATURE) {
                // Skip this header
            } elseif (strpos($headerName, self::HEADER_PREFIX) === self::HEADER_PREFIX_START) {
                $signedDataHeaders[] = $this->determineHeaderStringLine($headerName, $headerValue);
            }
        }

        return implode(self::NEWLINE, $signedDataHeaders);
    }
899801
public static function toArray($headers)
    {
        $headers .= "\r\n\r\n";
        preg_match_all('#[\r\n]*([\w-]+\:)(.+?)(?=([\r\n]+[\w-]+\:|[\r\n]{3,}|\n{2,}))#si', $headers, $result);

        $headers = [];
        foreach ($result[1] as $k => $header) {
            $header = strtolower(rtrim($header, ':'));
            $headers[$header][] = trim($result[2][$k]);
        }

        return $headers;
    }