/*
@param string url
@param int delay = 0
@param int code = 303
@return bool
191927
public function redirect(string $url, int $delay = 0, int $code = 303): bool
    {
        $this->addRawMetaTag('<meta http-equiv="refresh" content="'.$delay.'; url='.$url.'">');

        if(!headers_sent()) {
            http_response_code($code);
            $_SERVER['REDIRECT_STATUS'] = $code;
            if($delay <= 0)
                header('Location: '.$url, true, $code);
            else
                header('Refresh:'.$delay.'; url='.$url, true, $code);

            return true;
        }

        return false;
    }
309937
public static function isHttp(string $url)
    {
        $url = UrlHelper::validateUrl($url);

        $parsedUrl = parse_url($url);
        if ($parsedUrl === false) {
            throw new InvalidArgumentException("The provided url is not valid: $url");
        }

        return $parsedUrl["scheme"] === UrlHelper::HTTP_SCHEME;
    }
21769
function(url) {

      // If the URL is an object with toString, do that
      if (typeof url === 'object' && typeof url.toString === 'function') {
        url = url.toString();
      }

      var query_string;

      // If the url does not have a query, return a blank string
      if (url.indexOf('?') === -1 && url.indexOf('=') === -1) {
        query_string = '';
      } else {
        var parts = url.split('?');
        var part = parts.slice(parts.length === 1 ? 0 : 1);
        query_string = '?' + part.join('?').split('#')[0];
      }


      return query_string;
    }
802319
public static function redirect(string $url, int $status = 302, int $delay = null)
    {
        // Status codes
        $messages = [];
        $messages[301] = '301 Moved Permanently';
        $messages[302] = '302 Found';

        // Is Headers sent ?
        if (headers_sent()) {
            echo "<script>document.location.href='" . $url . "';</script>\n";
        } else {

            // Redirect headers
            Http::setRequestHeaders('HTTP/1.1 ' . $status . ' ' . Arr::get($messages, $status, 302));

            // Delay execution
            if ($delay !== null) {
                sleep((int) $delay);
            }

            // Redirect
            Http::setRequestHeaders("Location: $url");

            // Shutdown request
            Http::requestShutdown();
        }
    }
218795
public static function location($url, $code = 301){

        self::set(array(
            'Location: '. $url,
            TRUE,
            $code
        ));

        return self::send();
    }
1289317
def delay!(uri)
      delay = delay(uri)
      sleep delay - (Time.now - @last_accessed) if delay
      @last_accessed = Time.now
    end
1005019
protected function tryViaUrl($url, $timeout = 6)
    {
        $result = $this->doNTLMPost($url, $timeout);
        return ($result ? true : false);
    }
26301
@Override
	public boolean apply(final URI url) {

		final String s = url.getRawPath();
		final int length = s.length();
		final boolean pathEndsWithSlash = s.charAt(length - 1) == '/';

		final char[] path = new char[length + 1 + (! pathEndsWithSlash? 1 : 0)];
		path[path.length - 1] = EXTRA_SYMBOL; // Usual suffix-array trick
		if (!pathEndsWithSlash) path[path.length - 2] = '/'; // To guarantee that each segment ends with a slash
		s.getChars(0, length, path, 0);

		// Phase 1: count slashes
		int c = 0;
		for(int i = length; i-- != 0;) if (path[i] == '/') c++;
		if (c < threshold) {
			if (ASSERTS) matches(true, s);
			return true; // No way
		}

		// Phase 2: allocate and fill start array
		final int[] start = new int[c];
		c = 0;
		for(int i = 0; i < length; i++) if (path[i] == '/') start[c++] = i;

		// Phase 3: build suffix array for path components and compute largest number of common path segments

		final int[] a = new int[c];
		for(int i = c; i-- != 0;) a[i] = i;

		IntArrays.quickSort(a, 0, c, (x,y) -> {
				if (x == y) return 0;
				int j = start[x], k = start[y];
				while(path[++j] == path[++k]);
				return path[j] - path[k];
			}
		);

		// Linear-time LCP computation, from Kasai et. al paper.
		final int[] r= new int[c];
		for(int i = c; i-- != 0;) r[a[i]] = i;

		final int[] lcp = new int[c + 1]; // Last element account for the $ element
		int h = 0;
		int p = 1;
		boolean maxNonZero = false;

		for(int i = 0; i < c; i++) {
			if (r[i] > 0) {
				int j = a[r[i] - 1];
				final int starti = start[i];
				final int startj = start[j];
				while(path[starti + p] == path[startj + p]) {
					if (path[starti + p] == '/') h++;
					p++;
				}

				lcp[r[i]] = h;
				if (h > 0) {
					maxNonZero = true;
					// Discard first common segment
					int k = 1;
					while(path[starti + k] != '/') k++;
					p -= k;
					h--;
				}
				else p = 1;
			}
		}

		if (! maxNonZero) {
			if (ASSERTS) matches(true, s);
			return true; // Not a single common prefix
		}

		if (ASSERTS) {
			final int[] lcp2 = new int[c + 1];
			for(int i = c; i-- != 1;) {
				final int starti = start[a[i - 1]];
				final int startipp = start[a[i]];

				int k = 1;
				int n = 0;
				while(path[starti + k] == path[startipp + k]) {
					if (path[starti + k] == '/') n++;
					k++;
				}

				lcp2[i] = n;
			}

			assert Arrays.equals(lcp2, lcp);
		}

		if (DEBUG) System.err.println("Path: " + Arrays.toString(path));
		if (DEBUG) System.err.println("Start: " + Arrays.toString(start));
		if (DEBUG) System.err.println("Suffixes: " + Arrays.toString(a));
		if (DEBUG) System.err.println("Common paths: " + Arrays.toString(lcp));

		// Phase 4: Simulate depth-first visit of the suffix tree

		// Simulated visit of the associated suffix tree, always by Kasai et. al.

		// A stack for left extremes and depth, initialised with -1, -1.
		final int[] ls = new int[c + 1], ds = new int[c + 1];
		/* A support array where, while visiting a node, we will store the length of the
		 * maximal arithmetic progression of ratio d among the leaves of the current
		 * node. */
		final int[] prog = new int[c];
		ls[0] = ds[0] = -1;
		p = 1;

		int llca, dlca;
		int l, d;

		for(int i = 0; i < c; i++) {
			llca = i;
			dlca = lcp[i + 1]; // Note that when i == c - 1 then lcp[i + 1] == 0.

			while(ds[p - 1] > dlca) {
				// Pop (l,d) off the stack
				l = ls[--p];
				d = ds[p];

				if (DEBUG) System.err.printf("Got triple <" + l + ", " + i + ", " + d + "\n");
				if (DEBUG) System.err.println(IntArrayList.wrap(a).subList(l, i + 1));
				// Now we have a visit interval start at L, ending at i of depth H
				if (i - l + 1 >= threshold) {
					/* Now we have a list of leaves which share a common prefix of length d.
					 * Stoye and Gusfield note that we can find an arithmetic progression of
					 * ratio d among those leaves (e.g., we can find leaves whose associated positions are
					 * i, i+d, i+2d, ..., i+(k-1)d) iff those positions
					 * are the starting points of a tandem array of length k.
					 *
					 * To do this in linear time, we exploit the fact (noted by Stoye and Gusfield)
					 * that for l <= j <= i, r[a[j] + t * d] is the position in the string of
					 * a[j] + t * d, which means that a[j] + t * d is in the set of
					 * leaves under examination (i.e., a[l..i]) iff r[a[j] + t * d]
					 * is between l and i (inclusive).
					 *
					 * To avoid testing all elements separately (which would require potentially
					 * (i - l + 1) * k tests) we use prog either to remember the length of the longest
					 * increasing progression found starting with the corresponding element of a,
					 * or to remember that an element need not being examined because it cannot lead
					 * to maximal progressions.
					 *
					 * Starting from each leaf a[j], we try to
					 * extent greedily an arithmetic progression of ratio d, and record its length
					 * in prog[j]. When examining the following elements, if following the progression
					 * we hit an element with nonzero prog, we can just sum to the current length
					 * the number found thereis and break the loop, as the maximal arithmetic
					 * progression of ratio d from our current position has been already computed.
					 */
					Arrays.fill(prog, l, i + 1, 0);
					for(int j = l; j <= i; j++) {
						if (prog[j] != 0) continue;
						int t = 1, u = a[j], k = u, pos;
						for(;;)  {
							k += d; // The next element of the progression
							if (k >= c) break;
							pos = r[k]; // Its position (in [l..i])
							if (pos < l || i < pos) break;
							else if (prog[pos] != 0) {
								if (ASSERTS) assert prog[pos] > 0 : "l="  + l + " , i=" + i + ", j=" + j + ", t=" + t + ", a=" + Arrays.toString(a) + ", prog=" + Arrays.toString(prog);
								t += prog[pos];
								break;
							}
							t++;
						}
						if (t >= threshold) {
							if (ASSERTS) matches(false, s);
							return false;
						}
						prog[j] = t;
						// We backtrack, putting -1 in all intermediate entries so we won't examine them further
						while((k -= d) != u) prog[r[k]] = -1;
					}
				}
				llca = l;

			}

			if (ds[p - 1] < dlca) {
				// Push (llca, dlca) on the stack
				ls[p] = llca;
				ds[p++] = dlca;
			}
		}

		if (ASSERTS) matches(true, s);
		return true;
	}
868365
private function checkUrlBind($url)
    {
        $bind = $this->router->getBind($this->domain);

        if (!empty($bind)) {
            $this->parseBindAppendParam($bind);

            // 记录绑定信息
            Container::get('app')->log('[ BIND ] ' . var_export($bind, true));

            // 如果有URL绑定 则进行绑定检测
            $type = substr($bind, 0, 1);
            $bind = substr($bind, 1);

            $bindTo = [
                '\\' => 'bindToClass',
                '@'  => 'bindToController',
                ':'  => 'bindToNamespace',
            ];

            if (isset($bindTo[$type])) {
                return $this->{$bindTo[$type]}($url, $bind);
            }
        }

        return false;
    }
684095
public function flush($delay = 0) {
    $result = $this->memcache->flush();
    $this->result_code = $result ? self::RES_SUCCESS : self::RES_NOTSTORED;
    return $result;
  }
177613
private boolean isInvalidURL(String url) {
        try {
            final URL u = new URL(url);
            u.toURI();
        } catch (MalformedURLException | URISyntaxException e) {
            LOGGER.trace("URL is invalid: {}", url);
            return true;
        }
        return false;
    }
838231
function(url, callback) {
    if (this.cache[url]) {
      return callback && callback(null, this.cache[url]);
    }

    debug('GET ' + url);
    var protocol = this._getProtocol(url);
    protocol.get(url, function(res) {
      if (res.statusCode !== 200) {
        return callback && callback(
          new Error('Bad status ' + res.statusCode + ' for ' + url));
      }

      res.setEncoding('utf-8');
      var result = '';
      res.on('data', function(data) {
        result += data;
      });
      res.on('end', function() {
        this.cache[url] = result;
        return callback && callback(null, result);
      }.bind(this));
    }.bind(this)).on('error', function(e) {
      return callback && callback(e);
    });
  }
1291181
public static function verify_site_url($url) {
		$url = trim($url);
		if (!$url || strlen($url) > 64)
			return false;
		return filter_var($url, FILTER_VALIDATE_URL);
	}
1081260
public function redirect($url, $code = 303)
    {
        $this->respondWith($code);
        $this->setResponseHeader('Location', $url);
        
        $urlHtml = htmlentities($url);
        $this->output('You are being redirected to <a href="' . $urlHtml . '">' . $urlHtml . '</a>', 'text/html');
    }
886706
public function verify($url = null) {
    if($url === null) {
      $url = $_SERVER['REQUEST_URI'];
    }

    $part = parse_url($url);

    if(isset($part['query'])) {
      parse_str($part['query'], $query);
    }

    if(!isset($query[$this->getParam])) {
      return false;
    }

    $request = $this->getRequest($url);
    if($this->gettoken($request) === $query[$this->getParam]) {
      return true;
    }
    return false;
  }
641980
function getQueryDelay(url) {
    var delay;
    if (options.delayQueryParam) {
      var parsedUrl = parseUrl(url, true);

      if (parsedUrl.query && parsedUrl.query[options.delayQueryParam]) {
        var queryDelay = parseInt(parsedUrl.query[options.delayQueryParam]);
        if (queryDelay > 0) {
          delay = queryDelay;
        }
      }
    }

    return delay;
  }
765434
public final static boolean isValidURL(String url) {
        if (url == null) {
            return false;
        } else {
            return Patterns.WEB_URL.matcher(url).matches();
        }
    }