saves the referrer uri to session.

@param ServerRequestInterface $request
427766
private function saveReferrer(ServerRequestInterface $request)
    {
        Respond::session()->set(self::REFERRER, $request->getUri()->__toString());
    }
721937
protected function prepareRefundRequest($request, string $reference): RequestInterface
    {
        /** @var AbstractRequest $refundRequest */
        $refundRequest = $this->gateway()->refund($request);
        $refundRequest->setTransactionReference($reference);

        return $refundRequest;

    }
1293605
public function persist(RequestEntity $request)
    {
        $request->setId(str_random());
        $this->requests->insert($request);
    }
23732
public function getOptions(ServerRequestInterface $request): void
    {
        parent::getOptions($request);

        $this->surname = $request->get('surname', 'replace');
    }
178066
public function dispatch(ServerRequestInterface $request)
    {
        parse_str($request->getUri()->getQuery(), $args);
        $uri = '/';
        if (isset($args['page'])) {
            $uri .= $args['page'];
        }

        return $this->createDispatcher()->dispatch(
            $request->getMethod(),
            $uri
        );
    }
1148558
protected function storeCurrentUrl(Request $request, SessionInterface $session)
    {
        if ($request->getMethod() === 'GET') {
            $session->setPreviousUrl($request->fullUrl());
        }
    }
1235110
public function getOptions(ServerRequestInterface $request): void
    {
        parent::getOptions($request);

        $this->search  = $request->get('search', '');
        $this->replace = $request->get('replace', '');
        $this->method  = $request->get('method', 'exact');
        $this->case    = $request->get('case', '');

        $this->error = '';
        switch ($this->method) {
            case 'exact':
                $this->regex = preg_quote($this->search, '/');
                break;
            case 'words':
                $this->regex = '\b' . preg_quote($this->search, '/') . '\b';
                break;
            case 'wildcards':
                $this->regex = '\b' . str_replace([
                        '\*',
                        '\?',
                    ], [
                        '.*',
                        '.',
                    ], preg_quote($this->search, '/')) . '\b';
                break;
            case 'regex':
                $this->regex = $this->search;
                // Check for invalid regular expressions.
                // A valid regex on an empty string returns zero.
                // An invalid regex on an empty string returns false and throws a warning.
                try {
                    preg_match('/' . $this->search . '/', '');
                } catch (Throwable $ex) {
                    /* I18N: http://en.wikipedia.org/wiki/Regular_expression */
                    $this->error = '<div class="alert alert-danger">' . I18N::translate('The regular expression appears to contain an error. It can’t be used.') . '</div>';
                }
                break;
        }
    }
140522
public static function start(ServerRequestInterface $request): void
    {
        // Store sessions in the database
        session_set_save_handler(new SessionDatabaseHandler($request));

        $url    = (string) $request->getUri();
        $secure = parse_url($url, PHP_URL_SCHEME) === 'https';
        $domain = parse_url($url, PHP_URL_HOST);
        $path   = parse_url($url, PHP_URL_PATH);

        // Paths containing UTF-8 characters need special handling.
        $path = implode('/', array_map('rawurlencode', explode('/', $path)));

        session_name('WT_SESSION');
        session_register_shutdown();
        session_set_cookie_params(0, $path, $domain, $secure, true);
        session_start();

        // A new session? Prevent session fixation attacks by choosing a new session ID.
        if (!self::get('initiated')) {
            self::regenerate(true);
            self::put('initiated', true);
        }
    }
707977
public function verifyRequest(ServerRequestInterface $request)
    {
        $body   = $request->getParsedBody();
        $server = $request->getServerParams();

        return $this->verify(
            $body[self::CAPTCHA_NAME] ?? '',
            $server['REMOTE_ADDR'] ?? null
        );
    }
709894
protected function getSession(ServerRequestInterface $request): SessionInterface
    {
        if ($this->session === null) {
            $this->session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);

            if (!$this->session instanceof SessionInterface) {
                throw MissingSessionContainerException::create();
            }
        }

        return $this->session;
    }
1252957
protected function isPossibleToGetFromRequest(ServerRequestInterface $request)
    {
        if ($this->allowOverride instanceof OverridePolicyInterface) {
            $allowOverride = $this->allowOverride->isAllowToOverride($request);
        } else {
            $allowOverride = $this->allowOverride;
        }

        return $allowOverride === true && $request->hasHeader($this->requestHeader);
    }
951454
public function callback(ServerRequestInterface $request)
    {
        $response = new Response(200, [
            'Content-Type' => 'text/plain; charset=utf-8',
        ], '');

        return new Promise(function ($resolve, $reject) use (&$request, &$response) {
            try {
                $context = new Context($request, $response);
                $context->setLogger($this->getLogger());

                /**
                 * @var HttpBodyStream $body
                 */
                $body = $request->getBody();
                $body->on('data', function ($data) use (&$request, &$context) {
                    if (!$data) return;
                    $method = $request->getMethod();
                    $contentType = $request->getHeader('Content-Type');
                    if (isset($contentType[0])
                        && (strcasecmp($method, 'POST') === 0 || strcasecmp($method, 'PUT') === 0)
                    ) {
                        if (strpos(strtolower($contentType[0]), 'application/x-www-form-urlencoded') !== false) {
                            parse_str($data, $parsedBody);
                            $request = $request->withParsedBody($parsedBody);
                            $context->setRequest($request);
                        } else if (strpos(strtolower($contentType[0]), 'application/json') !== false) {
                            $parsedBody = json_decode($data, JSON_OBJECT_AS_ARRAY);
                            $request = $request->withParsedBody($parsedBody);
                            $context->setRequest($request);
                        }
                    }
                    $context->setAttribut('httpRawData', $data);
                });
                $body->on('end', function () use (&$context, $resolve) {
                    co(...$this->middlewares)($context);
                    $resolve($context->getReturn());
                });
                $body->on('error', function ($reason) use ($reject) {
                    $reject($reason);
                });
            } catch (\Throwable $exception) {
                // 触发错误异常处理中间件
                $this->onException($exception, $context);
                $rsp = $context->getResponse();
                if ($rsp === $response) {
                    $rsp = $response->withStatus(500);
                    $response->getBody()->write('Internal Server Error');
                }
                $resolve($rsp);
            }
        });
    }
260462
protected void redirectToReferrer() {
        String referrer = context.requestHeader("Referer");
        referrer = referrer == null? context.contextPath()/*injector.getInstance(DeploymentInfo.class).getContextPath()*/ : referrer;
        redirect(referrer);
    }
195482
public function handleRequest(\Psr\Http\Message\ServerRequestInterface $request)
    {
        // We define this constant, so that any TYPO3-Extension can check, if the REST-API is running
        define('REST_API_IS_RUNNING', true);

        // Dispatch the API-call
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $objectManager->get(Dispatcher::class)->dispatch();
    }
237769
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            // don't do anything if it's not the master request
            return;
        }

        $request = $event->getRequest();

        $referer = $request->headers->get('referer');

        if ($referer && false === mb_strpos($referer, $request->getHost())) {
            $session = $this->getContainer()->get('session');

            $session->set('referer', $referer);
        }
    }
659505
public function setModifierFromRequest(ServerRequestInterface $request)
    {
        $this->modifiers = [];

        $modifiers = $this->getParam($request, $this->getName());

        if (empty($modifiers)) {
            return;
        }

        if (is_string($modifiers)) {
            $modifiers = json_decode($modifiers, true);
            if (empty($modifiers)) {
                return;
            }
        } elseif (is_scalar($modifiers)) {
            return;
        }

        # Look if there is a filter over just one field, push it into an array to trick the foreach
        if (!array_key_exists(0, $modifiers)) {
            $modifiers = [$modifiers];
        }

        $this->modifiers = $modifiers;
    }
1234750
public function addReferrerToForm(FormInterface $form): void
    {
        $request = $this->get('request_stack')->getCurrentRequest();
        $form->add('http-referrer', HiddenType::class, [
            'mapped' => false,
            'data' => $request->headers->get('referer'),
        ]);
    }