Request Redirect
336197
public function redirect($path, $replace = true, $http_response_code = null, $response = null)
    {
        if ($this->isSingle()) {
            UrlManager::redirect($path, $replace, $http_response_code, $response);
        }
    }
481820
def get_redirect_url(self, request, **kwargs):
        
        if self.url:
            url = self.url % kwargs
            args = request.META.get('QUERY_STRING', '')
            if args and self.query_string:
                url = "%s?%s" % (url, args)
            return url
        else:
            return None
222329
def get_response(self, request):
        ''''''
        # the redirect key is already placed in the response by HttpResponseJavascriptRedirect
        return HttpResponseJavascriptRedirect(self.redirect_to, *self.args, **self.kwargs)
711151
def head(self, url, **kwargs):
        
        """

        kwargs.setdefault('allow_redirects', False)
        return self.request('HEAD', url, **kwargs)
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')
        ]);
    }
1171340
def param_redirect(request, viewname, *args):
    
    url = reverse(viewname, PARAMS_URL_CONF, args)
    params = request.GET.urlencode().split('&')

    if hasattr(request, 'cparam'):
        for k, v in request.cparam.items():
            params.append('{0}={1}'.format(k, v))

    new_params = '&'.join(x for x in params if x != '')
    if len(new_params) > 0:
        return HttpResponseRedirect('{0}?{1}'.format(url, new_params))
    return HttpResponseRedirect(url)
660718
function redirect() {
    l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + repo + '/?' +
      (l.pathname ? 'p=' + l.pathname.replace(/&/g, '~and~').replace(repo, '') : '') +
      (l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
      (l.hash))
  }
332737
protected function redirect()
    {
        $GLOBALS['eZRedirection'] = true;
        $ini = eZINI::instance();
        $automaticRedirect = true;

        if ( $GLOBALS['eZDebugAllowed'] && ( $redirUri = $ini->variable( 'DebugSettings', 'DebugRedirection' ) ) !== 'disabled' )
        {
            if ( $redirUri == "enabled" )
            {
                $automaticRedirect = false;
            }
            else
            {
                $uri = eZURI::instance( eZSys::requestURI() );
                $uri->toBeginning();
                foreach ( $ini->variableArray( "DebugSettings", "DebugRedirection" ) as $redirUri )
                {
                    $redirUri = new eZURI( $redirUri );
                    if ( $redirUri->matchBase( $uri ) )
                    {
                        $automaticRedirect = false;
                        break;
                    }
                }
            }
        }

        $redirectURI = eZSys::indexDir();

        $moduleRedirectUri = $this->module->redirectURI();
        if ( $ini->variable( 'URLTranslator', 'Translation' ) === 'enabled' &&
                eZURLAliasML::urlTranslationEnabledByUri( new eZURI( $moduleRedirectUri ) ) )
        {
            $translatedModuleRedirectUri = $moduleRedirectUri;
            if ( eZURLAliasML::translate( $translatedModuleRedirectUri, true ) )
            {
                $moduleRedirectUri = $translatedModuleRedirectUri;
                if ( strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] !== '/' )
                    $moduleRedirectUri = '/' . $moduleRedirectUri;
            }
        }

        if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) )
        {
            $redirectURI = $moduleRedirectUri;
        }
        else
        {
            $leftSlash = strlen( $redirectURI ) > 0 && $redirectURI[strlen( $redirectURI ) - 1] === '/';
            $rightSlash = strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] === '/';

            if ( !$leftSlash && !$rightSlash ) // Both are without a slash, so add one
                $moduleRedirectUri = '/' . $moduleRedirectUri;
            else if ( $leftSlash && $rightSlash ) // Both are with a slash, so we remove one
                $moduleRedirectUri = substr( $moduleRedirectUri, 1 );

            // In some cases $moduleRedirectUri can already contain $redirectURI (including the siteaccess).
            if ( !empty( $redirectURI ) && strpos( $moduleRedirectUri, $redirectURI ) === 0 )
            {
                $redirectURI = $moduleRedirectUri;
            }
            else
            {
                $redirectURI .= $moduleRedirectUri;
            }
        }

        // After the module redirect url is completed, add the queryString params so they carry over the redirect operation
        $redirectURI .= eZSys::queryString();

        if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
        {
            $staticCacheHandlerClassName = $ini->variable( 'ContentSettings', 'StaticCacheHandler' );
            $staticCacheHandlerClassName::executeActions();
        }

        eZDB::checkTransactionCounter();

        if ( !$automaticRedirect )
        {
            // Make sure any errors or warnings are reported
            if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
            {
                if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
                {
                    eZAppendWarningItem(
                        array(
                            'error' => array(
                                'type' => 'error',
                                'number' => 1,
                                'count' => $GLOBALS['eZDebugErrorCount']
                            ),
                            'identifier' => 'ezdebug-first-error',
                            'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
                        )
                    );
                }

                if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
                {
                    eZAppendWarningItem(
                        array(
                            'error' => array(
                                'type' => 'warning',
                                'number' => 1,
                                'count' => $GLOBALS['eZDebugWarningCount']
                            ),
                            'identifier' => 'ezdebug-first-warning',
                            'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
                        )
                    );
                }
            }

            $tpl = eZTemplate::factory();
            $tpl->setVariable( 'site', $this->site );
            $tpl->setVariable( 'warning_list', !empty( $this->warningList ) ? $this->warningList : false );
            $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) );
            $templateResult = $tpl->fetch( 'design:redirect.tpl' );

            eZDebug::addTimingPoint( "Script end" );

            eZDisplayResult( $templateResult );
            eZExecution::cleanExit();
        }

        return eZHTTPTool::redirect( $redirectURI, array(), $this->module->redirectStatus(), true, true );
    }
500213
private URI redirectUriUsing(HttpServletRequest request) {
        URI redirect;

        URI redirectUri = oAuth2ServiceProperties.getRedirectUri();
        if (!redirectUri.isAbsolute()) {
            redirect = UriBuilder.fromPath(request.getContextPath())
                    .path(redirectUri.toString())
                    .scheme(request.getScheme())
                    .host(request.getServerName())
                    .port(request.getServerPort())
                    .build();
        } else {
            redirect = redirectUri;
        }

            return redirect;
    }
363772
def get_redirect_url(self, request, callback, parameters=None):
        """"""
        args = self.get_redirect_args(request, callback=callback)
        additional = parameters or {}
        args.update(additional)
        params = urlencode(args)
        return '{0}?{1}'.format(self.authorization_url, params)
97854
private function needsRedirect()
    {
        /** @var int|string $id */
        $id = $this->getRequest()->param('ID');
        /** @var string $action */
        $action = $this->getRequest()->param('Action');
        /** @var array $handlers */
        $handlers = self::$url_handlers;
        if (array_key_exists($action, $handlers) && $handlers[$action] === 'show' && !$news = $this->getNews()) {
            if ($id && is_numeric($id)) {
                /** @var News $redirect */
                $redirect = $this->Newsitems()->byId($id);
                $this->redirect($redirect->Link(), 301);
            } else {
                /** @var Renamed $renamed */
                $renamed = Renamed::get()->filter(array('OldLink' => $id));
                if ($renamed->count() > 0) {
                    $this->redirect($renamed->First()->News()->Link(), 301);
                } else {
                    $this->redirect($this->Link(), 404);
                }
            }
        } elseif ($action === 'latest') {
            /** @var News $item */
            $item = News::get()->filter(array('Live' => true))->first();
            $this->redirect($item->Link(), 302);
        }
    }
1216998
def dispatch_request(self, *args, **kwargs):
        
        if request.method in ('POST', 'PUT'):
            return_url, context = self.post(*args, **kwargs)
            if return_url is not None:
                return redirect(return_url)
        elif request.method in ('GET', 'HEAD'):
            context = self.get(*args, **kwargs)
        return self.render_response(self.context(context))
917363
function redirect(url) {
    var path = u.urlPath(url);
    var params = u.urlParams(url);

    var pg = generator.aliase$[path];
    if (pg) return { status:301, url:pg._href + params };

    pg = generator.redirect$[path];
    if (pg) return { status:302, url:pg._href + params };

    // customRedirects return params also
    pg = generator.customRedirect && generator.customRedirect(url);
    if (pg) return { status:301, url:pg };
  }
1323931
def _redirect_url(request):
    

    next = request.GET.get(REDIRECT_FIELD_NAME)

    if not next:
        if settings.CAS_IGNORE_REFERER:
            next = settings.CAS_REDIRECT_URL
        else:
            next = request.META.get('HTTP_REFERER', settings.CAS_REDIRECT_URL)

        host = request.get_host()
        prefix = (('http://', 'https://')[request.is_secure()] + host)

        if next.startswith(prefix):
            next = next[len(prefix):]

    return next
32683
public static Response redirect(Request req, Key src_key) {
    return Response.redirect(req, "/2/Inspector", "src_key", src_key.toString());
  }
682512
def make_request(method, url, params):
    """"""
    empty = []

    # TODO
    # del params[key]
    # without list
    for key, value in six.iteritems(params):
        if value is None:
            empty.append(key)
    for key in empty:
        del params[key]

    # allow caller to disable automatic following of redirects
    allow_redirects = params.get('allow_redirects', True)

    kwargs = {
        'allow_redirects': allow_redirects,
        'headers': {
            'User-Agent': soundcloud.USER_AGENT
        }
    }
    # options, not params
    if 'verify_ssl' in params:
        if params['verify_ssl'] is False:
            kwargs['verify'] = params['verify_ssl']
        del params['verify_ssl']
    if 'proxies' in params:
        kwargs['proxies'] = params['proxies']
        del params['proxies']
    if 'allow_redirects' in params:
        del params['allow_redirects']

    params = hashconversions.to_params(params)
    files = namespaced_query_string(extract_files_from_dict(params))
    data = namespaced_query_string(remove_files_from_dict(params))

    request_func = getattr(requests, method, None)
    if request_func is None:
        raise TypeError('Unknown method: %s' % (method,))

    if method == 'get':
        kwargs['headers']['Accept'] = 'application/json'
        qs = urlencode(data)
        if '?' in url:
            url_qs = '%s&%s' % (url, qs)
        else:
            url_qs = '%s?%s' % (url, qs)
        result = request_func(url_qs, **kwargs)
    else:
        kwargs['data'] = data
        if files:
            kwargs['files'] = files
        result = request_func(url, **kwargs)

    # if redirects are disabled, don't raise for 301 / 302
    if result.status_code in (301, 302):
        if allow_redirects:
            result.raise_for_status()
    else:
        result.raise_for_status()
    return result
10941
public static void redirect(String url, boolean copyParameters, ServletRequest req, ServletResponse res)
	{
		if(url == null)
		{
			throw new IllegalArgumentException("URL cannot be null");
		}
		String redirectUrl = url;
		char separator = '?';
		if (redirectUrl.indexOf('?') != -1)
		{
			separator = '&';
		}
		if(copyParameters)
		{
			Enumeration e = req.getParameterNames();
			while (e.hasMoreElements())
			{
				String name = (String) e.nextElement();
				String value = req.getParameter(name);
				redirectUrl += separator + name + '=' + value;
				separator = '&';
			}
			e = req.getAttributeNames();
	/*		while (e.hasMoreElements())
			{
				String name = (String) e.nextElement();
				String value = req.getParameter(name);
				redirectUrl += separator + name + '=' + value;
				separator = '&';
			}  */
		}
		System.out.println(new LogEntry("about to redirect to " + redirectUrl));
		try
		{
			((HttpServletResponse)res).sendRedirect(redirectUrl);
		}
		catch(IOException ioe)
		{
			throw new ResourceException("redirect to '" + redirectUrl + "' failed with message: " +
			ioe.getMessage(), ioe);
		}
	}