@param Request $request
@param string  $header

@return null|Identifier
485639
private function getIdentifier(Request $request, $header)
    {
        if (null !== ($value = $request->headers->get($header))) {
            return Identifier::fromString($value);
        }

        return null;
    }
558932
public function beforeSend(Request $request)
    {
        $headers = array(
            self::X_AUTH_KEY => $this->data_store->getClientV4APIKey(),
            self::X_AUTH_EMAIL => $this->data_store->getCloudFlareEmail(),
            self::CONTENT_TYPE_KEY => self::APPLICATION_JSON_KEY,
        );
        $request->setHeaders($headers);

        // Remove cfCSRFToken (a custom header) to save bandwidth
        $body = $request->getBody();
        $body['cfCSRFToken'] = null;
        $request->setBody($body);

        return $request;
    }
1010385
public function setHeader($header = null)
    {
        if (is_null($header) && $this->getMethod() == "POST") {
            $host = $this->getHost();

            $header = [];
            $header[] = 'POST /cgi-bin/webscr HTTP/1.1';
            $header[] = 'Content-Type: application/x-www-form-urlencoded';
            if (isset($host)) {
                $header[] = 'Host: ' . $host;
            }
            $header[] = 'Connection: close';
        }
        $this->_aHeader = $header;
    }
730365
protected function requestIsInvalid(Request $request)
    {
        return empty($request->getBody()) && empty($request->getHeaders())
        && empty($request->getMethod()) && empty($request->getUrl());
    }
1194777
private function createToken(Request $request)
    {
        $tokenString = $request->headers->get($this->header);

        if ($this->header == self::HEADER_AUTH && 0 === strpos((string)$tokenString, 'Bearer ')) {
            $tokenString = substr($tokenString, 7);
        }

        if (!$tokenString) {
            return null;
        }

        return new JwtAuthenticationToken([], $tokenString);
    }
1249470
public function getRequestHeader($header)
    {
        $header = str_replace('-', '_', strtoupper($header));
        $value = $this->{'HTTP_' . $header};

        if (!$value) {
            $headers = $this->getRequestHeaders();
            $value = !empty($headers[$header]) ? $headers[$header] : null;
        }

        return $value;
    }
1360931
protected function getAcceptHeader(Request $request): Accept
	{
		$headerName = 'Accept';
		$headerLine = '*/*';
		if ($request->hasHeader($headerName))
		{
			$headerLine = $request->getHeaderLine($headerName);
		}
		try
		{
			return Accept::fromString($headerName . ': ' . $headerLine);
		}
		catch (\Exception $e)
		{
			throw new Exception\BadRequest('Invalid Accept header', $e);
		}
	}
138881
public function socket($request = null)
    {
        if (is_null($request) && ! $this->app->bound('request')) {
            return;
        }

        $request = $request ?: $this->app['request'];

        if ($request->hasHeader('X-Socket-ID')) {
            return $request->header('X-Socket-ID');
        }
    }
285770
private function resolveRequest(Request $request = null)
    {
        if (null === $request) {
            return $this->get('request_stack')->getCurrentRequest();
        }

        return $request;
    }
335986
public function setHttpHeader($header)
    {
        $headers = $this->getHttpHeaders();
        $headers[] = $header;
        $this->setHttpHeaders($headers);

    }
496768
private function authCookie(Request $request) {
		if ($request->cookies->has(self::COOKIE_TOKEN_NAME)) {
			$token = $request->cookies->get(self::COOKIE_TOKEN_NAME);
			return $this->authToken($token);
		}
		return null;
	}
71422
public function detect(Request $request)
	{
		if ($request->isMethod('post')) {
			return $request->request->get($this->parameterName);
		}

		return $request->query->get($this->parameterName);
	}
94424
public static function getHeadersFromRequest(Request $request)
    {
        $headers = array();
        foreach($request->headers as $key => $value)
        {
            if(isset($key) && isset($value) && isset($value[0]))
            {
                $headers[$key] = $value[0];
            }
        }
        return $headers;
    }
787639
private static function compareHeaderUrl(RequestInterface $request, string $headerName): bool
    {
        $headerValue = $request->getHeader($headerName);
        if ($headerValue === null) {
            // Header value not present.
            return true;
        }

        $headerUrl = Url::tryParse($headerValue);
        if ($headerUrl === null) {
            // Header value is not a valid url.
            return false;
        }

        return $headerUrl->getHost()->equals($request->getUrl()->getHost());
    }
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;
  }
385171
public function socket($request = null)
    {
        if (! $request && ! $this->container->bound('request')) {
            return null;
        }

        $request = $request ?: $this->container['request'];

        return $request->header('X-Socket-ID');
    }
1339468
public function get($header = null) {

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

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

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

    }