Set the URI for the next request

@param  Zend_Uri_Http|string $uri
@return Zend_Http_Client
@throws Zend_Http_Client_Exception
964424
public function setUri($uri)
    {
        if (is_string($uri)) {
            $uri = Zend_Uri::factory($uri);
        }

        if (!$uri instanceof Zend_Uri_Http) {
            /**
 * @see Zend_Http_Client_Exception 
*/
            include_once 'Zend/Http/Client/Exception.php';
            throw new Zend_Http_Client_Exception('Passed parameter is not a valid HTTP URI.');
        }

        // We have no ports, set the defaults
        if (! $uri->getPort()) {
            $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80));
        }

        $this->uri = $uri;

        return $this;
    }
838182
public function setUriRecurringPayments($uri = null)
    {
        $toSetUri = $uri;
        if(!$uri) {
            $toSetUri = $this->getUriPrefix().'recurringPayments';
        }

        $this->_uriRecurringPayments = $toSetUri;
    }
1368393
public function execute($uri)
    {
        foreach ($this->routes as $pattern => $callback) {
            if (preg_match($pattern, $uri, $params) === 1) {
                call_user_func_array($this->beforeRouteCallback, $params);
                array_shift($params);

                return call_user_func_array($callback, array_values($params));
            } else {
                error_log("$pattern did not match $uri");
            }
        }
    }
887238
protected function httpGet($uri)
    {
        $results = [];
        // Start requesting at page 1
        $page = 1;
        // We dont know how many pages there are, so assume 1 until we know
        $pagecount = 1;
        while ($page <= $pagecount) {
            $this->log[] = [
                        'request' => [
                                    'method' => 'GET',
                                    'uri'    => $uri.'?page='.$page,
                                    ],
                        ];
            $response = \Httpful\Request::get($uri.'?page='.$page)
                                                    ->addHeader('X-Auth-Email', $this->email)
                                                    ->addHeader('X-Auth-Key', $this->apikey)
                                                    ->expectsType(\Httpful\Mime::JSON)
                                                    ->parseWith(function ($body) {
                                                        return \Metaclassing\Utility::decodeJson($body);
                                                    })
                                                    ->send()
                                                    ->body;
            $this->log[count($this->log) - 1]['response'] = $response;
            if ($response['success'] != true) {
                throw new \Exception("get {$uri} unsuccessful".\Metaclassing\Utility::encodeJson($response));
            }
            foreach ($response['result'] as $result) {
                array_push($results, $result);
            }
            // Now that we KNOW the pagecount, update that and increment our page counter
            $pagecount = $response['result_info']['total_pages'];
            // And get the next page ready for the next request
            $page++;
        }

        return $results;
    }
476991
public function delete(string $uri)
    {
        $request = $this->getRequest($uri)
            ->setMethod('DELETE');

        return $this->send($request);
    }
733723
public function withUri(UriInterface $uri, $preserveHost = false)
    {
        if ($this->getUri() === $uri) {
            return $this;
        }

        $newInstance = clone $this;

        $newInstance->setUri($uri);
        if (!$preserveHost) {
            return $newInstance->withHeader('host', $uri->getHost());
        }
        return $newInstance;
    }
69132
public function setPort($port)
    {
        if ($this->validatePort($port) === false) {
            include_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port.");
        }

        $oldPort     = $this->_port;
        $this->_port = $port;

        return $oldPort;
    }
1012816
public function create($uri)
    {
        list($scheme, $host, $port, $path, $query, $fragment, $user, $pass) = $this->parseUrl($uri);

        return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass);
    }
267456
public function setPath($path)
    {
        if ($this->validatePath($path) === false) {
            require_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Path \"$path\" is not a valid HTTP path");
        }

        $oldPath     = $this->_path;
        $this->_path = $path;

        return $oldPath;
    }
644974
public function prepareHttp(string $uri)
    {
        $this->uri = $uri;

        // first, check the URI for duplicate slashes - they are not allowed
        // if you must pass duplicate slashes in URL, then urlencode them
        $redirect = null;
        if (strpos($this->uri, '//') !== false) {
            $redirect = str_replace('//', '/', $this->uri);
        }

        if (strlen($this->uri) > 1 && substr($this->uri, -1) == '/') {
            // ending slash is not needed, unless you have a namespace
            // if you need to pass slash on the end of URI, then urlencode it
            if ($redirect === null) {
                $redirect = substr($this->uri, 0, -1);
            } else {
                $redirect = substr($redirect, 0, -1);
            }
        }

        if ($redirect !== null) {
            header('Location: ' . Application::getDomainWithSchema() . $redirect);
            exit(0);
        }

        $questionPos = strpos($this->uri, '?');
        if ($questionPos !== false) {
            $this->uri = substr($this->uri, 0, $questionPos);
        }

        $ds = DS;

        $this->uri = explode('/', $this->uri);
        if (!isset($this->uri[1])) {
            $this->uri[1] = '';
        }

        // There are two possible scenarios:
        // 1. The first part of URL leads to the module controller
        // 2. The first part of URL leads to the default controller

        if ($this->uri[1] == '') {
            $this->controllerUrl = 'index';
            $this->controllerClass = 'IndexController';
        } else {
            $this->controllerUrl = strtolower($this->uri[1]);
            $this->controllerClass = str_replace(' ', '', ucwords(str_replace(['-', '.'], ' ', $this->controllerUrl))) . 'Controller';
        }

        // Now we have the controller class name detected, but, should it be
        // taken from module or from default controllers?

        $moduleDir = Application::getModulePath($this->controllerUrl);

        if (is_dir($moduleDir)) {
            Application::setCurrentModule($this->controllerUrl);

            // ok, it is a module with module/controller/action path
            $moduleUrl = $this->controllerUrl;
            $this->moduleUrl = $moduleUrl;

            if (isset($this->uri[2]) && $this->uri[2] != '') {
                $this->controllerUrl = strtolower($this->uri[2]);
                $this->controllerClass = str_replace(' ', '', ucwords(str_replace(['-', '.'], ' ', $this->controllerUrl))) . 'Controller';
            } else {
                $this->controllerUrl = 'index';
                $this->controllerClass = 'IndexController';
            }

            $this->controllerPath = "{$moduleDir}controllers{$ds}{$this->controllerClass}.php";
            $mainControllerExists = true;

            if (!is_file($this->controllerPath)) {
                // lets try with default controller when requested one is not here
                $this->controllerPath = Application::getModulePath($moduleUrl) . "controllers{$ds}IndexController.php";

                if (!is_file($this->controllerPath)) {
                    // Even IndexController is missing. Can not resolve that.
                    throw new NotFoundException("Can not find {$this->controllerClass} nor IndexController in {$moduleDir}{$ds}controllers");
                }

                $mainControllerExists = false;
                $this->controllerClass = 'IndexController';
            }

            if ($mainControllerExists) {
                if (!isset($this->uri[3]) || $this->uri[3] == '') {
                    $this->actionUrl = 'index';
                    $this->actionMethod = 'index';
                } else {
                    $this->actionUrl = strtolower($this->uri[3]);
                    $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                    $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                    $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
                }
            } else if (isset($this->uri[2]) && $this->uri[2] != '') {
                $this->actionUrl = strtolower($this->uri[2]);
                $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
            } else {
                $this->actionUrl = 'index';
                $this->actionMethod = 'index';
            }

        } else {

            // ok, it is the default controller/action
            $this->controllerPath = Application::getApplicationPath("controllers{$ds}{$this->controllerClass}.php");

            $mainControllerExists = true;

            if (!is_file($this->controllerPath)) {
                $this->controllerPath = Application::getApplicationPath("controllers{$ds}IndexController.php");

                if (!is_file($this->controllerPath)) {
                    // Even IndexController is missing. Can not resolve that.
                    throw new NotFoundException("Can not find {$this->controllerClass} nor IndexController in " . Application::getApplicationPath('controllers'));
                }

                $mainControllerExists = false;
                $this->controllerClass = 'IndexController';
            }

            if ($mainControllerExists) {
                if (!isset($this->uri[2]) || $this->uri[2] == '') {
                    $this->actionUrl = 'index';
                    $this->actionMethod = 'index';
                } else {
                    $this->actionUrl = strtolower($this->uri[2]);
                    $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                    $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                    $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
                }
            } else {
                $this->actionUrl = strtolower($this->uri[1]);
                $this->actionMethod = ucwords(str_replace(['-', '.'], ' ', $this->actionUrl));
                $this->actionMethod = str_replace(' ', '', $this->actionMethod);
                $this->actionMethod = strtolower(substr($this->actionMethod, 0, 1)) . substr($this->actionMethod, 1);
            }

            // and now, configure the include paths according to the case
            $basePath = Application::getApplicationPath();
            Application::addIncludePath($basePath . 'controllers',    // so you can extend abstract controllers in the same directory if needed,
              $basePath . 'library'      // the place where you can define your own classes and methods
            );
        }

        $this->isAjax = (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'],
              'application/json') !== false);

        $controllerClassName = $this->getControllerClass();

        if (!class_exists($controllerClassName)) {
            throw new Exception("Can not find class {$controllerClassName}; current include path is:\n" . get_include_path());
        }

        $controllerInstance = new $controllerClassName();

        $alwaysRestful = (isset($this->config['always_restful'])) && $this->config['always_restful'] === true;

        if ($alwaysRestful || (property_exists($controllerInstance, 'restful') && $controllerInstance::$restful === true)) {
            // it is restful
            $this->actionMethod = strtolower($_SERVER['REQUEST_METHOD']) . ucfirst($this->actionMethod);

        } else if ($this->isAjax) {
            $this->actionMethod .= 'Ajax';

        } else {
            $this->actionMethod .= 'Action';

        }

        $this->controllerInstance = $controllerInstance;
    }
109724
public function build($uri)
	{
		// Create the URI object
		$uri = $this->createUri($uri);

		// Process the uri information based on custom defined rules
		foreach ($this->rules['build'] as $rule)
		{
			$uri = $rule($uri);
		}

		return $uri;
	}
457719
public function route($uri = null)
    {
        if ($uri === null) {
            $uri = $this->getAppUri();
        }
        //$uri = ltrim(preg_replace('/^([^&]*)&.*$/', '$1', $uri), '/');
        
        $urlElements = parse_url($uri);
        $uri      = isset($urlElements['path'])     ? $urlElements['path']     : '';
        $query    = isset($urlElements['query'])    ? $urlElements['query']    : null;
        $fragment = isset($urlElements['fragment']) ? $urlElements['fragment'] : null;
        $urlTab = explode('/', trim($uri, ' /'));
        $request = Container::getRequest();
        $request->setUri($uri);
        $request->setBaseUrl($this->getBaseUrl());
        $controller = array_shift($urlTab);
        $action = array_shift($urlTab);
        $request->setController($controller ? $controller : self::DEFAULT_CONTROLLER);
        $request->setAction($action ? $action : self::DEFAULT_ACTION);
        while (count($urlTab)) {
            $key = trim(array_shift($urlTab));
            $value = array_shift($urlTab);
            if ($value !== null) {
                $request->setParam($key, $value);
            }
        }
        if ($query !== null) {
            $params = null;
            parse_str($query, $params);
            foreach ($params as $key => $value) {
                $request->setParam($key, $value);
            }
        }
        
        return $this;
    }
123608
protected static function setURI($uri){
        if(!is_string($uri)){
            throw new InvalidArgumentException(
                '$uri must be a string or null'
            );
        }
        self::$uri = filter_var($uri, FILTER_SANITIZE_URL);
    }
408511
public function setRequestUri(string $requestUri) : Request
    {
        $pos = strpos($requestUri, '?');

        if ($pos === false) {
            $this->path = $requestUri;
            $this->queryString = '';
            $this->query = [];
        } else {
            $this->path        = substr($requestUri, 0, $pos);
            $this->queryString = substr($requestUri, $pos + 1);

            if ($this->queryString === '') {
                $this->query = [];
            } else {
                parse_str($this->queryString, $this->query);
            }
        }

        $this->requestUri = $requestUri;

        return $this;
    }
493019
public function getUri()
    {
        if ($this->valid() === false) {
            require_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
        }

        $password = strlen($this->_password) > 0 ? ":$this->_password" : '';
        $auth     = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
        $port     = strlen($this->_port) > 0 ? ":$this->_port" : '';
        $query    = strlen($this->_query) > 0 ? "?$this->_query" : '';
        $fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';

        return $this->_scheme
             . '://'
             . $auth
             . $this->_host
             . $port
             . $this->_path
             . $query
             . $fragment;
    }
1048625
private function parse($uri)
    {
        $this->parsedUri = parse_url($uri);

        if (false === strstr($this->parsedUri['path'], $this->config->getRootEndpoint())) {
            throw RestException::invalidEndpoint($this->parsedUri['path']);
        }

        $this->adjustRootEndpoint($this->parsedUri['path']);

        $this->parsedUri['path'] = str_replace($this->config->getRootEndpoint(), '', $this->parsedUri['path']);
        $this->parsePath($this->parsedUri['path']);

        $this->parsedUri['query'] = isset($this->parsedUri['query']) ? $this->parsedUri['query'] : '';
        $this->parseQueryString($this->parsedUri['query']);

        return $this;
    }
1320217
public function get($uri)
    {
        $options = array(
            CURLOPT_URL => $this->domain.'/'.ltrim($uri, '/'),
            CURLOPT_FOLLOWLOCATION => 1,
            CURLOPT_RETURNTRANSFER => 1,
        );

        return $this->exec($options);
    }