Get the cookie header

@link https://github.com/philkra/elastic-apm-php-agent/issues/30

@return string
434242
final protected function getCookieHeader(string $cookieHeader) : string
    {
        $cookieMask = $this->contexts['cookies'];

        // Returns an empty string if cookies are masked.
        return empty($cookieMask) ? $cookieHeader : '';
    }
317209
public function getHeaders()
    {
        $headers = array_merge(
            $this->getRequestLineHeaders(),
            $this->getStandardHeaders(),
            $this->getCookieHeaders()
        );

        return $headers;
    }
550695
public function getHeaders()
    {
        $headers = static::getDefaultHeaders();

        if ($this->eTag) {
            $headers['If-None-Match'] = $this->eTag;
        }

        return array_merge($this->headers, $headers);
    }
121482
public function getCookie()
    {
        $request = Request::current();
        $settings = CsrfSettings::singleton();

        if ($request instanceof WebRequest){
            $existingCookie = $request->cookie(self::TOKEN_COOKIE_NAME, false);

            if ($existingCookie){
                $this->currentCookie = $existingCookie;
            }
        }

        if (!$this->currentCookie) {
            $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+";
            $cookie = "";
            for ($x = 0; $x < self::TOKEN_COOKIE_LENGTH; $x++) {
                $rand = rand(0, strlen($chars) - 1);
                $char = $chars[$rand];

                if (rand(0, 1) == 1) {
                    $char = strtolower($char);
                }

                $cookie .= $char;
            }

            $this->currentCookie = $cookie;

            HttpResponse::setCookie(self::TOKEN_COOKIE_NAME, $cookie, 0, '/', parse_url($settings->domain, PHP_URL_HOST), false, true);
        }

        return $this->currentCookie;
    }
1084239
function getCookieParams()
    {
        if ($this->_cookie === null) {
            $params = PhpServer::_($this->httpMessage)->getCookie();
            $this->_cookie = \Poirot\Std\cast($params)->toArray();
        }

        return $this->_cookie;
    }
150878
private function get_header_url(){
    return "wget -O - --quiet --http-user=" . $this->user . " --http-passwd=" . escapeshellarg($this->pass) . " --no-check-certificate 'https://" . $this->hostname . ":10000/".(
      $this->mode === 'cloudmin' ? 'server-manager' : 'virtual-server'
    )."/remote.cgi?json=1&multiline=&program=";
  }
910571
public function getHeadersAsString()
    {
        $headerString = '';
        foreach ($this->getHeaders() as $name => $header) {
            // build up a header string
            $headerString .= $name . ': ' . $header . PHP_EOL;
        }

        return $headerString;
    }
1099625
public function toString(): string
    {
        // first line
        $output = $this->buildFirstLine() . "\r\n";

        // add headers
        $output .= $this->headers->toHeaderLines(true);

        // append cookies
        // if ($cookie = $this->cookies->toRequestHeader()) {
        //     $output .= "Cookie: $cookie\r\n";
        // }

        $output .= "\r\n";

        return $output . $this->getBody();
    }
655044
public function toString()
    {
        $str = urlencode($this->name) . '=';

        if ((string)$this->value !== '' )
        {
            $str .= urlencode($this->value);

            if ($this->_expire !== 0) {
                $str .= '; expires=' . gmdate(DateTime::COOKIE, $this->_expire);
            }
        }
        else $str .= 'deleted; expires=' . gmdate(DateTime::COOKIE, time() - 31536001);

        if ($this->_path) {
            $str .= '; path=' . $this->_path;
        }

        if ($this->domain !== null) {
            $str .= '; domain=' . $this->domain;
        }

        if ($this->isSecure() === true) {
            $str .= '; secure';
        }

        if ($this->isHttpOnly() === true) {
            $str .= '; httponly';
        }

        return $str;
    }
901510
public function getHttpHeaders()
    {
        $headers = [];
        switch ($this->httpStatusCode) {
            case 401:
                $headers[] = 'HTTP/1.1 401 Unauthorized';
                break;
            case 500:
                $headers[] = 'HTTP/1.1 500 Internal Server Error';
                break;
            case 501:
                $headers[] = 'HTTP/1.1 501 Not Implemented';
                break;
            case 400:
            default:
                $headers[] = 'HTTP/1.1 400 Bad Request';
                break;
        }

        // Add "WWW-Authenticate" header
        //
        // RFC 6749, section 5.2.:
        // "If the client attempted to authenticate via the 'Authorization'
        // request header field, the authorization server MUST
        // respond with an HTTP 401 (Unauthorized) status code and
        // include the "WWW-Authenticate" response header field
        // matching the authentication scheme used by the client.
        // @codeCoverageIgnoreStart
        if ($this->errorType === 'invalid_client') {
            $authScheme = null;
            $request = new Request();
            if ($request->getUser() !== null) {
                $authScheme = 'Basic';
            } else {
                $authHeader = $request->headers->get('Authorization');
                if ($authHeader !== null) {
                    if (strpos($authHeader, 'Bearer') === 0) {
                        $authScheme = 'Bearer';
                    } elseif (strpos($authHeader, 'Basic') === 0) {
                        $authScheme = 'Basic';
                    }
                }
            }
            if ($authScheme !== null) {
                $headers[] = 'WWW-Authenticate: '.$authScheme.' realm=""';
            }
        }
        // @codeCoverageIgnoreEnd
        return $headers;
    }
1225218
public function toString()
    {
        $cookies = '';
        foreach ($this->getCookies() as $cookie) {
            $cookies .= 'Set-Cookie: '.$cookie."\r\n";
        }

        return parent::toString().$cookies;
    }
567311
public static function getAuthorizationHeader()
    {
        $headers = null;
        if (isset($_SERVER['Authorization'])) {
            $headers = trim($_SERVER["Authorization"]);
        } else if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
            $headers = trim($_SERVER["HTTP_AUTHORIZATION"]);
        } elseif (function_exists('apache_request_headers')) {
            $requestHeaders = apache_request_headers();
            $requestHeaders = array_combine(array_map(
                'ucwords',
                array_keys($requestHeaders)),
                array_values($requestHeaders)
            );
            if (isset($requestHeaders['Authorization'])) {
                $headers = trim($requestHeaders['Authorization']);
            }
        }
        return $headers;
    }
705318
public static function getModifiedSinceHeader()
    {
        $modifiedSince = '';
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            $modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];

            // strip any trailing data appended to header
            if (false !== ($semicolonPos = strpos($modifiedSince, ';'))) {
                $modifiedSince = substr($modifiedSince, 0, $semicolonPos);
            }
        }
        return $modifiedSince;
    }
338701
protected function getAccessToken() {
    $cookies = $_COOKIE;

    if (isset(\Drupal::request()->cookies)) {
      $cookies = \Drupal::request()->cookies->all();
    }

    $cookie_name = 'Drupal_visitor_' . $this->accessTokenCookie;

    if (isset($cookies[$cookie_name])) {
      return $cookies[$cookie_name];
    }

    return NULL;
  }
957354
public function getHeader()
	{
		$header = [];

		foreach ($this->columns as $column) {
			$header[] = $this->translator->translate($column->getName());
		}

		return $header;
	}
887566
public function get(): string
    {
        return $this->value($this->request->cookie(
            $this->config->key,
            $this->config->default
        ));
    }
1041260
public function getHeaderText(): string
    {
        $header      = $this->getHeaderElement();
        $header_text = $header->getText();
        $header_link = $header->find('css', 'a');

        // The page headers can often include an 'add new link'. Strip that out of the header text.
        if ($header_link) {
            $header_text = trim(str_replace($header_link->getText(), '', $header_text));
        }

        return $header_text;
    }