Generate a list of headers for given request

@param  array    $options Request options
@param  string   $body    Request body
@return string[]
969626
protected function generateHeaders(array $options, $body)
	{
		$options += ['headers' => []];
		if ($this->gzipEnabled)
		{
			$options['headers'][] = 'Accept-Encoding: gzip';
		}
		$options['headers'][] = 'Content-Length: ' . strlen($body);

		return $options['headers'];
	}
583102
protected function decodeXml($body)
    {
        try {
            $xml = Xml::build($body, ['return' => 'domdocument', 'readFile' => false]);
            // We might not get child nodes if there are nested inline entities.
            if ((int)$xml->childNodes->length > 0) {
                return Xml::toArray($xml);
            }

            return [];
        } catch (XmlException $e) {
            return [];
        }
    }
2888
protected function postRequest($uri, $body = null, $options = array())
    {
        if ($this->testMode) {
            $options['debug'] = true;
        }

        $headers = array(
            'Content-Type'               => 'application/json',
            'Accept'                     => 'application/json',
            'X-Verkkomaksut-Api-Version' => $this->apiVersion,
        );

        $options = array_merge(
            array(
                'auth'            => array($this->_apiKey, $this->_apiSecret),
                'timeout'         => 30,
                'connect_timeout' => 10,
            ),
            $options
        );

        $request = new Request('POST', $uri, $headers, $body);

        return $this->_client->send($request, $options);
    }
1228927
protected function response_headers_array(array $response_headers):array {
		$headers = [];

		foreach($response_headers as $key => $value){
			$headers[$key] = $value;
		}

		return $headers;
	}
707763
public function getLists(array $options = array())
    {

        $uri = $this->buildUserResourceUri('lists');
        $response = $this->makeAuthenticatedApiRequest($uri, $options);

        return $response->lists;

    }
707881
public static function toHeader($collection, $options = [])
    {
        $defaults = [
            'length'    => 0,
            'maxLength' => 0
        ];
        $options += $defaults;

        if (strtolower($collection->name()) === 'set-cookie') {
            $header = static::wrap($collection->name() . ': ' . join("\r\n" . $collection->name() . ': ', $collection->data()), $options['length']);
        } else {
            $header = static::wrap($collection->name() . ': ' . $collection->value(), $options['length']);
        }

        $maxLength = $options['maxLength'];
        if ($maxLength && preg_match('~^(.{' . $maxLength . ',})~m', $header)) {
            throw new RuntimeException("A header line with more that {$maxLength} characters has been detected.");
        }
        return $header;
    }
237743
public function listBucketsRequest($options=array())
    {
        $operation = array(
            'API' => 'ListBuckets',
            'Method' => 'GET',
            'Uri' => '/',
            'Headers' => array(
                'Host' => $this->config->host,
                'Location' => isset($options['Location'])?$options['Location']:null,
            ),
            'Params' => array(
            ),
            'Elements' => array(
            ),
            'Properties' => array(),
            'Body' => null
        );
        $this->listBucketsValidate($operation);
        $req = new Request($this->config, $operation);
        return $req;
    }
551467
private function options(array $options = [])
    {
        $options['query'] = array_merge(
            [
                'protover' => $this->api_protover,
                'clientver' => $this->app_version,
                'client' => $this->app_client,
            ],
            isset($options['query']) ? $options['query'] : []
        );

        $options['headers'] = array_merge(
            [
                'User-Agent' => $this->app_code,
            ],
            isset($options['headers']) ? $options['headers'] : []
        );

        return $options;
    }
612499
public function getList(array $options = array())
    {
        $uri = $this->buildListResourceUri($this->listId);
        $response = $this->makeApiRequest($uri, $options);
        return $response->list;
    }
112608
public function put($uri, $body = null, array $options = [])
    {
        return $this->request(self::REQUEST_METHOD_PUT, $uri, $body, $options);
    }
156459
public static function toArray($headers, $options = [])
    {
        $data = [];
        foreach ($headers as $name => $header) {
            if (strtolower($name) === 'set-cookie') {
                foreach ($header->data() as $value) {
                    $data[] = $name . ': ' . $value;
                }
            } else {
                $data[] = $name . ': ' . $header->value();
            }
        }
        return $data;
    }
1122524
private function getRequestHeaders() : array
    {
        // Default Headers Set
        $headers = [
            'Content-Type' => 'application/json',
            'User-Agent'   => sprintf('elasticapm-php/%s', Agent::VERSION),
        ];

        // Add Secret Token to Header
        if ($this->config->get('secretToken') !== null) {
            $headers['Authorization'] = sprintf('Bearer %s', $this->config->get('secretToken'));
        }

        return $headers;
    }
151140
protected function addOptionalHeaders($options)
    {
        if (!empty($options['headers'])) {
            foreach ((array) $options['headers'] as $header) {
                list($name, $value) = array_pad((array) $header, 2, null);
                $this->addHeader($name, $value);
            }
        }

        return $this;
    }
66355
private function parse($body)
    {
        $body = json_decode($body, true);

        if (empty($body)) {
            $body = array();
        }
        return new Options($body);
    }
1052777
private function getHeaders(array $userHeaders, $body): array
    {
        $headers = [
            'X-Contentful-User-Agent' => $this->userAgentGenerator->getUserAgent(),
            'Accept' => $this->apiContentType,
            'Accept-Encoding' => 'gzip',
            'Authorization' => 'Bearer '.$this->accessToken,
        ];

        if ($body) {
            $headers['Content-Type'] = $this->apiContentType;
        }

        return \array_merge($headers, $userHeaders);
    }
366932
public function put($url, $body = [], $headers = [], $options = [])
    {
        return $this->request('PUT', $url, $body, $headers, $options);
    }
1254567
protected function configureBody($body){
        $upload = $this->getUpload();
        switch ($this->method) {
            case self::HTTP_GET:
                if (!$upload){
                    if (is_array($body) || is_object($body)){
                        $queryParams = http_build_query($body);
                    } else {
                        $queryParams = $body;
                    }
                    if (!empty($body)){
                        if (strpos($this->url, "?") === false) {
                            $queryParams = "?".$queryParams;
                        } else {
                            $queryParams = "&".$queryParams;
                        }
                        return $this->configureUrl($this->url.$queryParams);
                    }
                    break;
                }
            default:
                if ($upload){
                    $this->addHeader('Content-Type','multipart/form-data');
                }
                return $this->addCurlOption(CURLOPT_POSTFIELDS, $body);
        }
    }