Create a new redirect response from the given path and arguments.

@return \Nova\Http\RedirectResponse
554641
public function url()
    {
        if (empty($parameters = func_get_args())) {
            return $this->to('/');
        }

        $path = array_shift($parameters);

        $result = preg_replace_callback('#\{(\d+)\}#', function ($matches) use ($parameters)
        {
            list ($value, $key) = $matches;

            return isset($parameters[$key]) ? $parameters[$key] : $value;

        }, $path);

        return $this->to($path);
    }
823457
public function addAction()
    {
        $request = $this->getRequest();
        $service = $this->getService();
        $form    = $this->getAddForm();

        //if ($this->getOptions()->getUseRedirectParameterIfPresent() && $request->getQuery()->get('redirect')) {
        if ($request->getQuery()->get('redirect')) {
            $redirect = $request->getQuery()->get('redirect');
        } else {
            $redirect = false;
        }

        $redirectUrl = $this->url()->fromRoute($this->getAddActionRoute())
                     . ($redirect ? '?redirect=' . $redirect : '');

        $prg = $this->prg($redirectUrl, true);

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
                'options'  => $this->getOptions(),
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        $post   = $prg;
        $entity = $service->create($post);

        $redirect = isset($prg['redirect']) ? $prg['redirect'] : null;

        if (!$entity) {
            return array(
                'options'  => $this->getOptions(),
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        // TODO: Add the redirect parameter here...
        return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix()) . ($redirect ? '?redirect='.$redirect : ''));
    }
761733
public static function redirect($path, $param = [], $add = '')
    {
        Deprecated::method(3.0);

        return new RedirectResponse(self::path($path, $param, $add));
    }
1227891
protected function httpPost(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        return $this->httpPostRaw($path, $this->createRequestBody($parameters), $requestHeaders);
    }
967464
async def redirect(self, path, status = 302):
        
        location = urljoin(urlunsplit((b'https' if self.https else b'http',
                                                                     self.host,
                                                                     quote_from_bytes(self.path).encode('ascii'),
                                                                     '',
                                                                     ''
                                                                     )), path)
        self.start_response(status, [(b'Location', location)])
        await self.write(b'<a href="' + self.escape(location, True) + b'">' + self.escape(location) + b'</a>')
        await self.flush(True)
1330954
public function redirectToRoute()
    {
        if ($this->getRequest()
                 ->isXmlHttpRequest()) {
            return [
                'redirect' => call_user_func_array(
                    [
                        $this->url(),
                        'fromRoute',
                    ],
                    func_get_args()
                ),
            ];
        }

        return call_user_func_array(
            [
                $this->redirect(),
                'toRoute',
            ],
            func_get_args()
        );
    }
1013650
public function redirectToAction(
        Action $action,
        array $parameters = [],
        $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH,
        $status = 302
    ): RedirectResponse {
        $url = $this->adminRouter->generateAdminPath(
            $action->getAdmin(),
            $action->getCode(),
            $parameters,
            $referenceType
        );

        return new RedirectResponse($url, $status);
    }
1186269
public function redirect($path, $status = 301)
    {
        if (!$this->asWidget) {
            /** @var ResponseInterface $response */
            $response = (new ResponseInjector)->build();
            if (!$response) {
                throw new Exception('Component `response` not configured');
            }

            $response = $response->withStatus($status);
            $response = $response->getHeaderLine('Location: '.$path);

            return $response;
        }

        return false;
    }
892615
public static function to(?string $path = '/', ?int $code = null)
  {
    $redirect = new Redirect;
    $redirect->url = $path;

    if ($code !== null) {
      $redirect->code = $code;
      return $redirect->send();
    }

    return $redirect;
  }
107400
public function redirectIntended()
    {
        // Make sure we have a route.
        if (is_null($this->route)) {
            throw new \Exception('No route has been provided.  Please use route() to add one.');
        }

        // If this response passed, show the success message.
        if ($this->success) {
            return redirect()
                ->intended($this->route)
                ->with('message', $this->message);
        }

        // If this response failed, show the error message.
        return redirect($this->route)
            ->with('error', $this->message);
    }
974083
public function redirect() : RedirectResponse {
        if( ! $this->notified) {
            $this->notify();
        }

        $url = $this->url ?: app(UrlGenerator::class)->previous();

        return response()->redirectTo($url);
    }
1245318
protected function _redirect()
    {
        $request = $this->_controller->request;
        return $this->_controller->redirect([
            'prefix'     => $request->getParam('prefix'),
            'plugin'     => $request->getParam('plugin'),
            'controller' => $request->getParam('controller'),
            'action'     => $this->getConfig('action')
        ]);
    }
304227
public function redirectToPath($path, $parameters = array())
    {
        $route = $this->getRouter()->generate($path, $parameters);

        return $this->redirect($route);
    }
239929
public function create($path)
    {
        $folders = explode('/', trim(preg_replace('#/+#', '/', $path), '/'));
        $lastFolderId = self::ROOT_DIR_ID;

        foreach ($folders as $name) {

            $command = new CreateFolder($name, $lastFolderId);
            $response = ResponseFactory::getResponse($this->contentClient, $command);

            if ($response instanceof SuccessResponse) {

                if ($response->getStatusCode() == 201) {
                    $lastFolderId = $response->json()['id'];
                    usleep(250);
                    continue;
                }

            } elseif ($response instanceof ErrorResponse) {

                if ($response->getStatusCode() == 409) {
                    $lastFolderId = reset($response->json()['context_info']['conflicts'])['id'];
                    usleep(250);
                    continue;
                }

                throw new \Exception($response->getStatusCode() . (string)$response->getBody());
            }
        }

        if (is_null($lastFolderId)) {
            throw new \Exception();
        }

        return $lastFolderId;
    }
119213
protected function createRedirectResponse($url, $code = 301)
    {
        $response = $this->getComponentResponseFactory()
            ->createComponentResponse();

        $response->setCode($code)
                 ->getHeaders()
                    ->setHeader('Location', $url);

        return $response;
    }
1115865
public function newAction(Request $request)
    {
        $redirection = new Redirection();

        $form = $this->getRedirectionForm($redirection, '#new-redirection-form-container');
        $form->handleRequest($request);

        if ($request->query->get('novalidate', false) === false) {
            if ($form->isValid()) {
                if ($redirection->getLink()->getLinkType() !== Link::TYPE_NONE) {
                    $em = $this->getDoctrine()->getManager();
                    $em->persist($redirection);
                    $em->flush();

                    $this->congrat($this->get('translator')->trans('victoire.redirection.create.success'));

                    return new Response($this->renderView('@VictoireSeo/Redirection/_newForm.html.twig', [
                        'isOpened'  => true,
                        'form'      => $this->getRedirectionForm(new Redirection(), '#new-redirection-form-container')->createView(),
                        'icTrigger' => [
                            'target' => '#redirections-list-container',
                            'url'    => $this->generateUrl('victoire_redirection_showListItem', [
                                'id' => $redirection->getId(),
                            ]),
                        ],
                    ]), 200, [
                        'X-Inject-Alertify' => true,
                    ]);
                } else {
                    // force form error when no link submitted
                    $form->addError(new FormError('This value should not be blank.'));
                }
            } else {
                $this->warn($this->get('translator')->trans('victoire.404.form.error.unvalid'));
            }

            return new Response($this->renderView('@VictoireSeo/Redirection/_newForm.html.twig', [
                'form'     => $form->createView(),
                'isOpened' => true,
            ]), 200, [
                'X-Inject-Alertify' => true,
            ]);
        }

        // rebuild form to avoid wrong form error
        $form = $this->getRedirectionForm($redirection, '#new-redirection-form-container');

        return new JsonResponse([
            'html' => $this->renderView('@VictoireSeo/Redirection/_newForm.html.twig', [
                'form'      => $form->createView(),
                'isOpened'  => true,
            ]),
        ]);
    }
625777
protected function registerRedirect()
    {
        $this->app->singleton('redirect', function ($app) {
            $redirect = new Redirector($app['url']);

            $redirect->setSession($app['session']);

            return $redirect;
        });
    }