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;
    }