URL back-routed into application request object.

@param string|NULL $url URL or NULL for current URL.
@return \Nette\Application\Request
763327
public function getAppRequest($url = NULL)
	{
		$httpRequest = new \Nette\Http\Request($this->getUrlScriptForUrl($url ? : $this->url()));
		return $this->context->router->match($httpRequest);
	}
1298867
public function url($url = null)
    {
        if (!is_null($url) && true !== $url) {
            $this->url = $url;
            return $this;
        } elseif (!$this->url) {
            if ($this->isCli()) {
                $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
            } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
                $this->url = $_SERVER['HTTP_X_REWRITE_URL'];
            } elseif (isset($_SERVER['REQUEST_URI'])) {
                $this->url = $_SERVER['REQUEST_URI'];
            } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
                $this->url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
            } else {
                $this->url = '';
            }
        }
        return true === $url ? $this->domain() . $this->url : $this->url;
    }
1273399
public function get( $url ) {
		$this->assertString( 'url', $url );

		if ( !isset( $this->conn ) ) {
			$this->connect();
		}

		$this->setCurlGetOpts( $url );

		return $this->request();
	}
1242431
public function run($url = null) {
        if ($url) {
            $this->curl->setUrl($url);
        }

        if ($this->curl instanceof MultiCurl) {
            $this->curl->start();
        } else {
            $this->curl->exec();
        }

        return $this->fetch();
    }
1369876
public function setUrl($url)
    {
        $this->currentUrl = $url;
        $this->misc->setUrl($url);

        return $this;
    }
427043
public function get($url)
    {

        curl_setopt($this->handle, CURLOPT_POST, 0); // Added to clear past values
        curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, 'GET'); // Added to clear past values

        return $this->execute($url);
    }
865368
static public function getRootUrl($url=null)
	{
	    if (!$url || strpos($url, '://') === false) {
            $schema = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
            $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTP_HOST');
            $domain = static::GetRootDomain($domain);
            $baseUrl = $domain ? $schema . $domain : '';
            $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null;
	    } else {
	        $parts = parse_url($url);
	        $domain = static::GetRootDomain($parts['host']);
	        $baseUrl = $parts['scheme'] . '://' . $domain;
	        $port = isset($parts['port']) ? $parts['port'] : '';
	    }
	    if ($port && $port != 80 && $port != 443) {
	        $baseUrl .= ':'.$port;
	    }
	    
	    return $baseUrl;
	}
393603
protected function createUrl($url)
    {
        // is absolute URL?
        if (strpos($url, '://')) {
            return Url::createFromUrl($url);
        }

        // only query and path matters in relative url
        $url = Url::createFromUrl($url);
        $query = $this->baseUrl->getQuery();
        $path = $this->baseUrl->getPath();

        $query->modify($url->getQuery());
        $path->append($url->getPath());

        return $this->baseUrl->setQuery($query)->setPath($path);
    }
219243
public function url(string $url) : self
    {
        $this->route = $url;

        $this->active($url);

        return $this;
    }
268876
public static function redirect($url = null)
    {
        if ($url === null or empty($url)) {
            $base_url = self::siteBaseUrl();
        } elseif ($url === 'self') {
            $base_url = self::siteUrl();
        } elseif ($url === 'prev') {
            $base_url = self::previous();
        } else {
            $base_url = $url;
        }
        ob_start();
        (new Redirect($base_url, 200));
    }
1338982
public function getRoute($url)
    {
        $routes = $this->_route->getRoutes();
        $return = '';
        foreach ($routes as $route) {
            $routeURI = $this->_config->from('app')->get('basepath').$route['uri'];

            // POST requests
            if (isset($_POST)) {
                foreach ($_POST as $key => $value) {
                    $route['query'][] = [$key => $value];
                }
            }

            // GET requests
            $getexp = explode('?', $_SERVER['REQUEST_URI']);
            if (isset($getexp[1])) {
                if (implode('?', $getexp) == $routeURI.'?'.$getexp[1]) {
                    $route['querystring'] = $getexp[1];
                    $qexp = explode('&', $route['querystring']);
                    foreach ($qexp as $q) {
                        $i = explode('=', $q);
                        $route['query'][] = [$i[0] => $i[1]];
                    }
                }
            }

            // For handling routes with variables
            $expressionExp = explode('/', $route['uri']);
            $serveruri = '/'.substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], $expressionExp[1]));
            $serveruriexp = explode('/', $serveruri);

            for ($i = 0; $i < count($expressionExp); $i++) {
                $expressionExp[$i] = preg_replace_callback('/\{(.+)\}/', function ($m) use ($serveruriexp, $i, &$route) {
                    $route['query'][] = [$m[1] => $serveruriexp[$i]];

                    return strtolower($serveruriexp[$i]); // url hack to accept upper cases too
                }, $expressionExp[$i]);
            }

            $expression = implode('/', $expressionExp);
            $route['uri'] = $expression;

            if (isset($route['querystring'])) {
                $checkurl = $route['uri'].'?'.$route['querystring'];
            } else {
                $checkurl = $route['uri'];
            }

            if ((strtolower($checkurl) == $url) && ($_SERVER['REQUEST_METHOD'] == $route['method'])) {
                return $route;
            }
        }
    }
145569
public function downloadFileFromURL($url)
    {
        $request     = new \Google_Http_Request($url, 'GET', null, null);
        $httpRequest = $this->service->getClient()
           ->getAuth()
           ->authenticatedRequest($request);
        if ($httpRequest->getResponseHttpCode() == 200) {
            return $httpRequest->getResponseBody();
        } else {
            // An error occurred.
            return null;
        }
    }
1263443
private function matchUrl($url)
    {
        $request = Request::create($url);
        $this->requestAnalyzer->analyze($request);

        try {
            return null !== $this->router->matchRequest($request);
        } catch (ResourceNotFoundException $exception) {
            return false;
        }
    }
76639
public function url($url = null)
    {
        if ($url) {
            $command = $this->getDriver()->factoryCommand('url', WebDriver_Command::METHOD_POST, ['url' => $url]);
            //protect slowest pages and lost selenium connection
            try {
                $this->getDriver()->curl($command);
            } catch (WebDriver_NoSeleniumException $mainException) {
                if (!$this->config()->get(WebDriver_Config::IMPROVED_URL_OPEN)) {
                    throw $mainException;
                }
                try {
                    $currentUrl = $this->url();
                    $partCheck = [PHP_URL_PATH, PHP_URL_QUERY, PHP_URL_HOST];
                    $isEqual = true;
                    foreach ($partCheck as $urlPart) {
                        if (parse_url($url, $urlPart) != parse_url($currentUrl, $urlPart)) {
                            var_dump(parse_url($url, $urlPart));
                            $isEqual = false;
                        }
                    }
                    if (!$isEqual) {
                        throw $mainException;
                    }
                } catch (WebDriver_NoSeleniumException $e) {
                    throw $mainException;
                }
            }
        } else {
            $result = $this->getDriver()->curl(
                $this->getDriver()->factoryCommand('url', WebDriver_Command::METHOD_GET)
            );
            return $result['value'];
        }
    }
1217473
public static function getUrl()
    {
        if (static::isCLI()) {
            return null;
        }

        if (static::$url === null) {
            $url = 'http';
            if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
                $url .= 's';
            }
            $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            static::$url = new Url($url);
        }

        return static::$url;
    }
297413
public static function factory($url)
    {
        static $defaults = array('scheme' => null, 'host' => null, 'path' => null, 'port' => null, 'query' => null,
            'user' => null, 'pass' => null, 'fragment' => null);

        if (false === ($parts = parse_url($url))) {
            throw new InvalidArgumentException('Was unable to parse malformed url: ' . $url);
        }

        $parts += $defaults;

        // Convert the query string into a QueryString object
        if ($parts['query'] || 0 !== strlen($parts['query'])) {
            $parts['query'] = QueryString::fromString($parts['query']);
        }

        return new static($parts['scheme'], $parts['host'], $parts['user'],
            $parts['pass'], $parts['port'], $parts['path'], $parts['query'],
            $parts['fragment']);
    }
21661
public function init($url = null)
    {
        $url       = (empty($url) ? Server::getInstance()->getCurrentUri() : $url);
        $this->url = parse_url($url);

        return $this;
    }