Return the HandlerExecutionChain for this request
@param ServletRequestInterface $servletRequest current HTTP request
@return HandlerExecutionChain the HandlerExecutionChain or {@code null} is no handler could be found
330665
protected function getHandler(ServletRequestInterface $servletRequest)
    {
        foreach ($this->handlerMappings as $handlerMapping) {
            $handler = $handlerMapping->getHandler($servletRequest);
            if ($handler != null) {
                return $handler;
            }
        }
        return null;
    }
1239347
static String getServletPath(HttpServletRequest request) {
    String servletPath = request.getServletPath();
    if (hackWorks && PACKAGE.equals(request.getClass().getPackage().getName())) {
      try {
        Object outer = get(request, "this$0");
        Object servletPipeline = get(outer, "servletPipeline");
        Object servletDefs = get(servletPipeline, "servletDefinitions");
        int length = Array.getLength(servletDefs);
        for (int i = 0; i < length; ++i) {
          Object pattern = get(Array.get(servletDefs, i), "patternMatcher");
          if (matches(pattern, servletPath)) {
            servletPath = extractPath(pattern, servletPath);
            break;
          }
        }
      } catch (Exception e) {
        hackWorks = false;
      }
    }
    return servletPath;
  }
887206
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $tokenValue = $this->getToken();

        $this->validate($request, $tokenValue);

        // Attach Request Attributes
        $request = $request->withAttribute('csrf_token', $tokenValue);

        /* @var Response $response */
        $response = $handler->handle($request);

        return $this->injectTokenToResponse($response, $tokenValue);
    }
23052
protected function getToken(ServerRequestInterface $request)
    {
        $token = $this->getTokenFromHeader($request, $this->getConfig('header'));
        if ($token === null) {
            $token = $this->getTokenFromQuery($request, $this->getConfig('queryParam'));
        }

        $prefix = $this->getConfig('tokenPrefix');
        if ($prefix !== null && is_string($token)) {
            return $this->stripTokenPrefix($token, $prefix);
        }

        return $token;
    }
245258
private function getResolverHandlerChain()
    {
        $randomResolver = $this->resolverFactory->create(Random::class);
        $nonMutualResolver = $this->resolverFactory->create(NonMutual::class, $randomResolver);

        return $this->resolverFactory->create(FromExistingPair::class, $nonMutualResolver);
    }
663536
public function execute(RequestInterface $request): RequestInterface
    {
        if (is_null($this->sessionToken)) {
            return $request;
        } else {
            return $request->withHeader(
                self::HEADER_CLIENT_AUTHENTICATION,
                [$this->sessionToken->getToken()]
            );
        }
    }
359366
public static ActionResolver getCurrentActionResolver( HttpServletRequest request )
    {
        ServletContext servletContext = InternalUtils.getServletContext( request );
        return getCurrentActionResolver( request, servletContext );
    }
151631
public static HttpServletRequest getOuterRequest( HttpServletRequest request )
    {
        ScopedRequest scopedRequest = unwrapRequest( request );
        return scopedRequest != null ? scopedRequest.getOuterRequest() : request;
    }
120697
protected function _getDigest(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $digest = empty($server['PHP_AUTH_DIGEST']) ? null : $server['PHP_AUTH_DIGEST'];
        if (empty($digest) && function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') {
                $digest = substr($headers['Authorization'], 7);
            }
        }
        if (empty($digest)) {
            return null;
        }

        return $this->parseAuthData($digest);
    }
474177
public function process(Request $request, RequestHandlerInterface $delegate): ResponseInterface
    {
        try {
            return $delegate->handle($request);
        } catch (\Throwable $t) {
            return $this->handleException($t, $request);
        }
    }
802450
protected function getRequestToken(Request $request)
    {
        /** @var TokenExtractorInterface $tokenExtractor */
        foreach ($this->tokenExtractors as $tokenExtractor) {
            if (($token = $tokenExtractor->extract($request))) {
                return $token;
            }
        }
    }
1109821
private FilterChain getChainForName(int requestType, ServletHolder servletHolder) {
        if (servletHolder == null) {
            throw new IllegalStateException("Named dispatch must be to an explicitly named servlet");
        }
        
        if (_filterChainsCached)
        {
            synchronized(this)
            {
                if (_namedChainCache[requestType].containsKey(servletHolder.getName()))
                    return (FilterChain)_namedChainCache[requestType].get(servletHolder.getName());
            }
        }
        
        // Build list of filters
        Object filters= null;
        
        if (jsr154Filter!=null)
        {
            // Slight hack for Named servlets
            // TODO query JSR how to apply filter to all dispatches
            filters=LazyList.add(filters,jsr154FilterHolder);
        }
        
        // Servlet filters
        if (_servletFilterMap.size() > 0)
        {
            Object o= _servletFilterMap.get(servletHolder.getName());
            for (int i=0; i<LazyList.size(o);i++)
            {
                FilterMapping mapping = (FilterMapping)LazyList.get(o,i);
                if (mapping.appliesTo(null,requestType))
                    filters=LazyList.add(filters,mapping.getHolder());
            }
        }

        FilterChain chain = null;
        if (_filterChainsCached)
        {
            synchronized(this)
            {
                if (LazyList.size(filters) > 0)
                    chain= new CachedChain(filters, servletHolder);
                _namedChainCache[requestType].put(servletHolder.getName(),chain);
            }
        }
        else if (LazyList.size(filters) > 0)
            chain = new Chain(filters, servletHolder);
        
        return chain;   
    }
1070339
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // service data
        $data = $request->getAttribute(PackerMiddleware::ATTRIBUTE_DATA);

        $method    = $data['method']??"";
        $version   = $data['version']??"";
        $interface = $data['interface']??"";

        /* @var \Swoft\Rpc\Server\Router\HandlerMapping $serviceRouter */
        $serviceRouter  = App::getBean('serviceRouter');
        $serviceHandler = $serviceRouter->getHandler($interface, $version, $method);

        // deliver service data
        $request = $request->withAttribute(self::ATTRIBUTE, $serviceHandler);

        return $handler->handle($request);
    }
461109
public function execute(RequestInterface $request): RequestInterface
    {
        if ($request->getUri()->getPath() === self::ENDPOINT_INSTALLATION) {
            return $request;
        } else {
            $signature = $this->determineRequestSignature(
                $request->getUri(),
                $request->getMethod(),
                $request->getBody()->getContents(),
                $request->getHeaders()
            );

            return $request->withHeader(self::HEADER_CLIENT_SIGNATURE, $signature);
        }
    }
327096
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if (empty($this->handler)) {
            throw new HttpException("Unable to run HttpCore, no handler is set.");
        }

        return $this->pipeline->withHandler($this->handler)->handle($request);
    }
687501
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Most requests will need the current tree and user.
        $ged  = $request->getQueryParams()['ged'] ?? $request->getParsedBody()['ged'] ?? '';
        $tree = Tree::findByName($ged);

        // No tree specified/available?  Choose one.
        if ($tree === null && $request->getMethod() === RequestMethodInterface::METHOD_GET) {
            $tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM')) ?? array_values(Tree::getAll())[0] ?? null;
        }

        // Most layouts will require a tree for the page header/footer
        View::share('tree', $tree);

        // Need a closure, as the container does not allow you to bind null.
        app()->bind(Tree::class, static function () use ($tree): ?Tree {
            return $tree;
        });

        return $handler->handle($request);
    }
830660
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        /** @var Tree|null $tree */
        $tree = app(Tree::class);

        // The tree exists, we have access to it, and it is fully imported.
        if ($tree instanceof Tree && $tree->getPreference('imported') === '1') {
            return redirect(route('tree-page', ['ged' => $tree->name()]));
        }

        // Not logged in?
        if (!Auth::check()) {
            return redirect(route('login', ['url' => (string) $request->getUri()]));
        }

        // No tree or tree not imported?
        if (Auth::isAdmin()) {
            return redirect(route('admin-trees'));
        }

        return $this->viewResponse('errors/no-tree-access', ['title' => '']);
    }