protected function getTrustedProxyHeaderValues($type, ServerRequestInterface $request)
    {
        if (isset($this->settings['headers']) && is_string($this->settings['headers'])) {
            $trustedHeaders = $this->settings['headers'];
        } else {
            $trustedHeaders = $this->settings['headers'][$type] ?? '';
        }
        if ($trustedHeaders === '' || !$request->getAttribute(Request::ATTRIBUTE_TRUSTED_PROXY)) {
            yield null;
            return;
        }
        $trustedHeaders = array_map('trim', explode(',', $trustedHeaders));

        foreach ($trustedHeaders as $trustedHeader) {
            if (!$request->hasHeader($trustedHeader)) {
                continue;
            }
            if (strtolower($trustedHeader) === 'forwarded') {
                $forwardedHeaderValue = $this->getForwardedHeader($type, $request->getHeader($trustedHeader));
                if ($forwardedHeaderValue !== null) {
                    yield $forwardedHeaderValue;
                }
            } else {
                yield array_map('trim', explode(',', $request->getHeader($trustedHeader)));
            }
        }

        yield null;
    }
protected function getTrustedProxyHeaderValues($type, ServerRequestInterface $request)
    {
        if (isset($this->settings['headers']) && is_string($this->settings['headers'])) {
            $trustedHeaders = $this->settings['headers'];
        } else {
            $trustedHeaders = $this->settings['headers'][$type] ?? '';
        }
        if ($trustedHeaders === '' || !$request->getAttribute(Request::ATTRIBUTE_TRUSTED_PROXY)) {
            yield null;
            return;
        }
        $trustedHeaders = array_map('trim', explode(',', $trustedHeaders));

        foreach ($trustedHeaders as $trustedHeader) {
            if (!$request->hasHeader($trustedHeader)) {
                continue;
            }
            if (strtolower($trustedHeader) === 'forwarded') {
                $forwardedHeaderValue = $this->getForwardedHeader($type, $request->getHeader($trustedHeader));
                if ($forwardedHeaderValue !== null) {
                    yield $forwardedHeaderValue;
                }
            } else {
                yield array_map('trim', explode(',', $request->getHeader($trustedHeader)));
            }
        }

        yield null;
    }
protected function getTrustedProxyHeaderValues ( $ type , ServerRequestInterface $ request ) { if ( isset ( $ this -> settings [ 'headers' ] ) && is_string ( $ this -> settings [ 'headers' ] ) ) { $ trustedHeaders = $ this -> settings [ 'headers' ] ; } else { $ trustedHeaders = $ this -> settings [ 'headers' ] [ $ type ] ?? '' ; } if ( $ trustedHeaders === '' || ! $ request -> getAttribute ( Request :: ATTRIBUTE_TRUSTED_PROXY ) ) { yield null ; return ; } $ trustedHeaders = array_map ( 'trim' , explode ( ',' , $ trustedHeaders ) ) ; foreach ( $ trustedHeaders as $ trustedHeader ) { if ( ! $ request -> hasHeader ( $ trustedHeader ) ) { continue ; } if ( strtolower ( $ trustedHeader ) === 'forwarded' ) { $ forwardedHeaderValue = $ this -> getForwardedHeader ( $ type , $ request -> getHeader ( $ trustedHeader ) ) ; if ( $ forwardedHeaderValue !== null ) { yield $ forwardedHeaderValue ; } } else { yield array_map ( 'trim' , explode ( ',' , $ request -> getHeader ( $ trustedHeader ) ) ) ; } } yield null ; }
Get the values of trusted proxy header.

@param string $type One of the HEADER_* constants
@param ServerRequestInterface $request The request to get the trusted proxy header from
@return \Iterator An array of the values for this header type or NULL if this header type should not be trusted
Get the values of trusted proxy header .