checks if server redirects url
766949
def check_if_redirect(url):
    
    response = head(url, headers={'User-Agent': USER_AGENT})
    if response.status_code >= 300 and response.status_code < 400:
        return response.headers['location']

    return None
14423
def server_check(arg):
    
    if arg.startswith(('http://', 'https://', 'http+unix://')):
        return arg
    if arg.startswith('./'):
        arg = os.path.abspath(arg)
    elif not arg.startswith('/'):
        raise argparse.ArgumentTypeError(
            'Unix socket path must start with / or ./')
    # assume it is a unix socket
    return 'http+unix://{}'.format(url_escape(arg, ''))
202543
protected function validateRedirectURL()
    {
        if (!filter_var($this->redirectURL, FILTER_VALIDATE_URL)) {
            // Not a full URL
            if (!preg_match('#^/[a-zA-Z0-9_/.-]*#', $this->redirectURL)) {
                // Not a valid path either
                $this->setNotReady("Invalid redirect URL entered.", null, 404);
                return;
            }
        }
    }
287453
private function checkForTrailingSlashRedirect()
    {
        if (!empty($this->segments) && empty($this->segments[count($this->segments) - 1])) {
            //Trim off the empty segment
            array_pop($this->segments);

            $newUrl = $this->baseHREF . '/' . implode('/', $this->segments);

            header("Location: " . $newUrl);
            exit();
        }
    }
155683
public boolean isHttpRedirect() {
		if (isRevisitDigest() && (getDuplicatePayload() != null)) {
			return getDuplicatePayload().isHttpRedirect();
		}
		String httpCode = getHttpCode();
		return (httpCode.startsWith("3"));
	}
570551
function isUrl (obj) {
    if(isString(obj)){
        if((obj.indexOf('http://') > -1 || obj.indexOf('https://') > -1) 
        	&& obj.indexOf('.') > -1)
        	return true
        else
        	return false
    }else{
        return false;
    }
}
786442
def get_redirect_location(self):
        
        if self.status in self.REDIRECT_STATUSES:
            return self.headers.get('location')

        return False
515917
protected function checkRequestRemovalFilter()
	{
		if ($key = Yii::app()->getRequest()->getParam($this->removeFilterVar))
			if ($this->jsonStorage->removeData($key, $this->registry))
				Yii::app()->getController()->redirect($this->redirectRoute);
	}
943127
def safe_redirect(next_url, default=None):
    
    if is_legit_next_url(next_url):
        return redirect(next_url)

    if default:
        return redirect(default)

    return redirect('/')
290284
private boolean isRedirectNeeded(final HttpMethod method) {
		switch (method.getStatusCode()) {
			case HttpStatus.SC_MOVED_TEMPORARILY:
			case HttpStatus.SC_MOVED_PERMANENTLY:
			case HttpStatus.SC_SEE_OTHER:
			case HttpStatus.SC_TEMPORARY_REDIRECT:
				LOG.debug("Redirect required");
                if (method.getFollowRedirects()) {
                    return true;
                } else {
                    return false;
                }
			default:
				return false;
		} //end of switch
	}
266591
protected function checkReferer()
    {
        if (!empty($_SERVER['HTTP_REFERER'])) {
            $url = parse_url($_SERVER['HTTP_REFERER']);

            $hostUrl = (array_key_exists('port', $url)) ? $url['host'].':'.$url['port'] : $url['host'];

            if ($hostUrl != $_SERVER['HTTP_HOST']) {
                session_destroy(); // destroy fake session
            }
        }
    }
618151
def validate_redirect_uri(value):
    
    sch, netloc, path, par, query, fra = urlparse(value)
    if not (sch and netloc):
        raise InvalidRedirectURIError()
    if sch != 'https':
        if ':' in netloc:
            netloc, port = netloc.split(':', 1)
        if not (netloc in ('localhost', '127.0.0.1') and sch == 'http'):
            raise InsecureTransportError()
791238
private function mustRedirect(ServerRequestInterface $request): bool
    {
        if ($this->redirect === false) {
            return false;
        }

        return !$this->checkHttpsForward || (
            $request->getHeaderLine('X-Forwarded-Proto') !== 'https' &&
            $request->getHeaderLine('X-Forwarded-Port') !== '443'
        );
    }
9535
private String getRedirectUrl(HttpServletRequest request, String newScheme) {
    String serverName = request.getServerName();
    String uri = request.getRequestURI();

    StringBuilder redirect = new StringBuilder(100);
    redirect.append(newScheme);
    redirect.append("://");
    redirect.append(serverName);
    redirect.append(uri);

    String query = request.getQueryString();
    if (query != null) {
      redirect.append('?');
      redirect.append(query);
    }

    return redirect.toString();
  }
418190
protected function checkPermissionRedirect()
    {
        if (!$this->user->hasAccess('backend.access_dashboard')) {
            $true = function () { return true; };
            if ($first = array_first(BackendMenu::listMainMenuItems(), $true)) {
                return Redirect::intended($first->url);
            }
        }
    }
928223
def __pre_check(self, requestedUrl):
		'''
		
		'''
		components = urllib.parse.urlsplit(requestedUrl)

		netloc_l = components.netloc.lower()
		if netloc_l in Domain_Constants.SUCURI_GARBAGE_SITE_NETLOCS:
			self.__check_suc_cookie(components)
		elif netloc_l in Domain_Constants.CF_GARBAGE_SITE_NETLOCS:
			self.__check_cf_cookie(components)
		elif components.path == '/sucuri_shit_2':
			self.__check_suc_cookie(components)
		elif components.path == '/sucuri_shit_3':
			self.__check_suc_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_2':
			self.__check_cf_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_3':
			self.__check_cf_cookie(components)
747185
def is_permanent_redirect(self):
        """"""
        return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect))