Transform an the OAuth array configuration to HTTP headers OAuth string.

@param array $oauth

@return string
765855
private function encodeOAuthHeaders(&$oauth)
    {
        $values = [];
        foreach ($oauth as $key => &$value) {
            $values[] = $key.'="'.\rawurlencode($value).'"';
        }

        return 'OAuth '.\implode(', ', $values);
    }
700197
public static function get_headers() {
    $headers = OAuthUtil::get_headers_internal();
    if ( ! is_array($headers) ) return $headers;
    if ( (! isset($headers['Authorization'])) && isset($headers['X-Oauth1-Authorization']) ) {
        $headers['Authorization'] = $headers['X-Oauth1-Authorization'];
    }
    return $headers;
  }
41993
protected function convertJwtToOAuth2($tokenData)
    {
        $keyMapping = array(
            'aud' => 'client_id',
            'exp' => 'expires',
            'sub' => 'user_id'
        );

        foreach ($keyMapping as $jwtKey => $oauth2Key) {
            if (isset($tokenData[$jwtKey])) {
                $tokenData[$oauth2Key] = $tokenData[$jwtKey];
                unset($tokenData[$jwtKey]);
            }
        }

        return $tokenData;
    }
486685
private function prepareHeaders($headers)
    {
        $headers = array_merge($this->defaultHeaders, $headers);

        if ($this->shopId && $this->shopPassword) {
            $encodedAuth              = base64_encode($this->shopId.":".$this->shopPassword);
            $headers["Authorization"] = "Basic ".$encodedAuth;
        } else if ($this->bearerToken) {
            $headers["Authorization"] = 'Bearer '.$this->bearerToken;
        }

        if (empty($headers['Authorization'])) {
            throw new AuthorizeException('Authorization headers not set');
        }

        $headers = array_map(function ($key, $value) {
            return $key.":".$value;
        }, array_keys($headers), $headers);


        return $headers;
    }
31119
private static function serverToHeaders(array $server)
    {
        $headers = array();
        foreach ($server as $key => $value) {
            if (strpos($key, 'HTTP_') === 0) {
                $key = strtolower(str_replace("_", '-', substr($key, 5)));
                $headers[$key] = $value;
            }
        }
        return $headers;
    }
452970
private function calculateHeader(array $parameters, $url)
        {
            // divide into parts
            $parts = parse_url((string) $url);

            // init var
            $chunks = array();

            // process queries
            foreach ($parameters as $key => $value) {
                $chunks[] = str_replace(
                    '%25', '%',
                    self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"'
                );
            }

            // build return
            $return = 'Authorization: OAuth realm="", ';
            $return .= implode(',', $chunks);

            // prepend name and OAuth part
            return $return;
        }
451851
protected function makeDataToSign($auth_header)
    {
        $query = '';
        if (isset($this->config['query']) && $this->config['query']) {
            $query .= '?';
            if (is_string($this->config['query'])) {
                $query .= $this->config['query'];
            } else {
                $query .= $this->buildQueryString($this->config['query']);
            }
        }

        $data = array(
            strtoupper($this->httpMethod),
            'https',
            $this->host,
            $this->path . $query,
            $this->canonicalizeHeaders(),
            (strtoupper($this->httpMethod) === 'POST') ? $this->makeContentHash() : '',
            $auth_header
        );

        return implode("\t", $data);
    }
210317
public static function split_header($header, $only_allow_oauth_parameters = true) {
    $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
    $offset = 0;
    $params = array();
    while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
      $match = $matches[0];
      $header_name = $matches[2][0];
      $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
      if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
        $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
      }
      $offset = $match[1] + strlen($match[0]);
    }

    if (isset($params['realm'])) {
      unset($params['realm']);
    }

    return $params;
  }
869030
public function to_header($realm=null)
    {
        $first = true;
        if($realm) {
            $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
            $first = false;
        } else
            $out = 'Authorization: OAuth';
        $total = [];
        foreach ($this->parameters as $k => $v) {
            if (substr($k, 0, 5) != "oauth") continue;
            if (is_array($v)) {
                throw new OAuthException('Arrays not supported in headers');
            }
            $out .= ($first) ? ' ' : ',';
            $out .= OAuthUtil::urlencode_rfc3986($k) .
                  '="' .
                  OAuthUtil::urlencode_rfc3986($v) .
                  '"';
            $first = false;
        }
        return $out;
    }
1191166
private function buildAuthorizationHeader($authorizationParams)
    {
        $authorizationString = 'OAuth ';
        foreach ($authorizationParams as $key => $val) {
            if ($val) {
                $authorizationString .= $key . '="' . urlencode($val) . '", ';
            }
        }

        return substr($authorizationString, 0, -2);
    }
371128
private function setHttpResponse(OAuth2Response $response)
    {
        $httpResponse = $this->getResponse();
        $httpResponse->setStatusCode($response->getStatusCode());

        $headers = $httpResponse->getHeaders();
        $headers->addHeaders($response->getHttpHeaders());
        $headers->addHeaderLine('Content-type', 'application/json');

        $httpResponse->setContent($response->getResponseBody());
        return $httpResponse;
    }
141303
private function buildAuthorizationHeader($oauth)
    {
        $r      = 'Authorization: OAuth ';
        $values = $this->normalizeParameters($oauth);
        $r .= str_replace('&', ', ', $values);

        return $r;
    }
433521
public static function splitHeader( $header, $oauthOnly = true ) {
		$re = '/(' . ( $oauthOnly ? 'oauth_' : '' ) .
			'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/';
		$params = [];
		if ( preg_match_all( $re, $header, $m ) ) {
			foreach ( $m[1] as $i => $h ) {
				$params[$h] = static::urldecode(
					empty( $m[3][$i] ) ? $m[4][$i] : $m[3][$i]
				);
			}
			if ( isset( $params['realm'] ) ) {
				unset( $params['realm'] );
			}
		}
		return $params;
	}
228153
public function to_header($realm=null)
    {
        $first = true;
        if($realm) {
            $out = 'Authorization: OAuth realm="' . Util::urlencode_rfc3986($realm) . '"';
            $first = false;
        } else
            $out = 'Authorization: OAuth';

        foreach ($this->parameters as $k => $v) {
            if (substr($k, 0, 5) != "oauth") continue;
            if (is_array($v)) {
                throw new Exception('Arrays not supported in headers');
            }
            $out .= ($first) ? ' ' : ',';
            $out .= Util::urlencode_rfc3986($k) .
                '="' .
                Util::urlencode_rfc3986($v) .
                '"';
            $first = false;
        }
        return $out;
    }
517173
public static function normalizeServer(array $server)
    {
        // This seems to be the only way to get the Authorization header on Apache
        if (
            isset($server['HTTP_AUTHORIZATION']) ||
            !\function_exists('\apache_request_headers')
        ) {
            return $server;
        }

        $apacheRequestHeaders = \apache_request_headers();

        if (
            isset($apacheRequestHeaders[$name = 'Authorization']) ||
            isset($apacheRequestHeaders[$name = 'authorization'])
        ) {
            $server['HTTP_AUTHORIZATION'] = $apacheRequestHeaders[$name];

            return $server;
        }

        return $server;
    }
149351
public function authHeaders(array $headers = [ ])
    {
        if (count($headers) == 0) {
            $headers = [ 'X-Application' => Auth::$appKey, 'X-Authentication' => Auth::$sessionToken ];
        }
        $this->options[ 'headers' ] = array_merge($this->options[ 'headers' ], $headers);
        return $this;
    }
718281
public function getAuthorizationHeader($url, array $params, array $overrides = [])
    {
        $headers = $this->prepareHeaders('POST', $url, $params, $overrides);

        $headers = implode(',', array_map(function($name, $value){
            return sprintf('%s="%s"', $name, $value);
        }, array_keys($headers), $headers));

        return sprintf('OAuth realm="",%s', $headers);
    }