@param  string $url
@param  string $requestMethod
@param  array  $params

@throws OmiseException

@return string
974154
private function _executeCurl($url, $requestMethod, $key, $params = null)
    {
        $ch = curl_init($url);

        curl_setopt_array($ch, $this->genOptions($requestMethod, $key.':', $params));

        // Make a request or thrown an exception.
        if (($result = curl_exec($ch)) === false) {
            $error = curl_error($ch);
            curl_close($ch);

            throw new Exception($error);
        }

        // Close.
        curl_close($ch);

        return $result;
    }
516998
protected function appendParamsToUrl(string $url, array $params): string
    {
        if (empty($params['_fields'])) {
            unset($params['_fields']);
        }

        if (empty($params)) {
            return $url;
        }

        // If the _fields param is set transform it to a single string so that
        // it's not urlencoded as an array
        if (isset($params['_fields']) && \is_array($params['_fields'])) {
            $params['_fields'] = array_unique(array_merge($params['_fields'], ['id']));
            $params['_fields'] = implode(',', $params['_fields']);
        }

        // If there is no question mark in the URL we can just add the params
        // to the query string and exit early
        if (strpos($url, '?') === false) {
            return $url . '?' . http_build_query($params, '', '&');
        }

        list($path, $query) = explode('?', $url, 2);

        parse_str($query, $existingParams);

        $params = array_merge($params, $existingParams);

        return $path . '?' . http_build_query($params, '', '&');
    }
798505
protected function RemoveQueryString($url, Request $request)
    {
        if (isset($url) && !empty($url)) {
            $parts = explode('&', $url);

            if (strpos($parts[0], '=') === false) {
                $url = $parts[0];
            } else {
                $url = self::RemoveQueryString($request->getQueryString());
            }
        }

        return $url;
    }
989541
private function request($url, $params = [], $method = 'GET')
    {
        // Set URL & Header
        curl_setopt($this->curl, CURLOPT_URL, $this->url . $url);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, array());

        //Add post vars
        if($method == 'POST')
        {
            curl_setopt($this->curl, CURLOPT_POST, count($params));
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params);
        }

        //Get result
        $result = curl_exec($this->curl);
        if($result === false)
            throw new \Exception('CURL error: ' . curl_error($this->curl));

        // decode results
        $result = json_decode($result, true);

        if(!is_array($result) || json_last_error())
            throw new \Exception('JSON decode error');

        return $result;

    }
524799
public function makeRedirectUri($uri, $params = [], $queryDelimiter = '?')
    {
        $uri .= (strstr($uri, $queryDelimiter) === false) ? $queryDelimiter : '&';

        return $uri . http_build_query($params);
    }
711407
public function execGET($url, array $params = [])
    {
        $url = $this->baseUrl . $url;

        // Build the query from the parameters
        if ($params !== []) {
            $url .= '?' . http_build_query($params);
        }

        // Set request options
        $this->addOptions([
            CURLOPT_URL => $url,
            CURLOPT_HTTPGET => true,
        ]);

        return $this->exec();
    }
210761
private static function getSelfUrlParams($requestParams, $paramsNew, $opts)
    {
        $params = $requestParams;
        $paramsQuery = Str::parse($_SERVER['QUERY_STRING']);    // params from QUERY_STRING
        // compare $_GET with QUERY_STRING & REQUEST_URI to see what's been added/removed/changed
        //  if a param has changed between QUERY_STRING & $_GET, it will be added as a default
        //  if in QUERY_STRING, but not in REQUEST_URI, it will NOT be added as a default
        $cor = array_diff_assoc($paramsQuery, $_GET);   // Changed Or Removed params
        $coa = array_diff_assoc($_GET, $paramsQuery);   // Changed Or Added params
        foreach ($cor as $k => $v) {
            if (!isset($coa[$k])) {
                unset($params[$k]); // it's a remove
            } elseif (isset($coa[$k]) && $coa[$k] != $v) {
                continue;   // $_GET[param] has changed in code
            } elseif (!isset($requestParams[$k])) {
                // $k is in QUERY_STRING, but not REQUEST_URI (mod_rewrite created)
                unset($coa[$k]);
            }
        }
        foreach ($coa as $k => $v) {
            $params[$k] = $v;       // it's a change or add
        }
        if (!empty($opts['getLock'])) {
            foreach ($opts['getLock'] as $k) {
                if (isset($params[$k])) {
                    $params[$k] = isset($requestParams[$k])
                        ? $requestParams[$k]    // use REQUEST_URI val
                        : null;                         // not in REQUEST_URI
                }
            }
        }
        if (!$opts['keepParams']) {
            // keep default params only if in getProp
            foreach ($params as $k => $v) {
                if (!in_array($k, $opts['getProp'])) {
                    unset($params[$k]);
                }
            }
        }
        foreach ($paramsNew as $k => $v) {
            $params[$k] = $v;
        }
        return $params;
    }
886012
protected static function combineUrl($url, $params = [])
    {
        $urlObject = Url::parse($url);
        $queryData = array_merge($urlObject->query->getData(), $params);
        $urlObject->query->setData($queryData);

        return $urlObject->getUrl();
    }
274314
public function post($url, array $params = [])
    {
        return $this->request($this->createUrl($url), self::METHOD_POST, $params);
    }
94947
public static function addParameter($url, $params)
    {
        if (!$url) {
            return $url;
        }
        if ($params) {
            if (is_array($params)) {
                $newParams = [];
                foreach ($params as $key => $item) {
                    $newParams[] = $key . '=' . $item;
                }
                $params = join('&', $newParams);
            }
            return $url . (strstr($url, '?') ? '&' : '?') . $params;
        }
        return $url;
    }
1123747
public function execute($uri, $requestMethod)
    {
        foreach ($this->routes as $route) {
            if (true === $route->matches($uri, $requestMethod)) {
                return $route;
            }
        }
        return null;
    }
486470
protected function calculateOptionsForParams(string $requestMethod, array $params, string $accessToken): array
    {
        $options = $this->prepareBaseOptions($accessToken);
        if (0 === \count($params)) {
            return $options;
        }

        switch ($requestMethod) {
            case RequestMethodEnum::GET:
            case RequestMethodEnum::DELETE:
                $options['query'] = $params;
                break;
            case RequestMethodEnum::PUT:
            case RequestMethodEnum::POST:
                $options['form_params'] = $params;
                break;
            case RequestMethodEnum::UPLOAD:
                if (array_key_exists('resource', $params) && array_key_exists('name', $params)) {
                    $options['headers']['X-File-Name'] = $params['name'];
                    $options['multipart'] = [
                        [
                            'contents' => $params['resource'],
                            'name' => $params['name'],
                        ],
                    ];
                }
                break;
            default:
                throw new \InvalidArgumentException(sprintf('Request method "%s" not allowed!', $requestMethod));
        }

        return $options;
    }
1313838
public function getHttpMethodOmissionsAsArray()
    {

        // initialize the array for the HTTP method omissions
        $httpMethodOmissions = array();

        // prepare the HTTP method omissions
        /** @var \AppserverIo\Appserver\Core\Api\Node\HttpMethodOmissionNode $httpMethodOmissionNode */
        foreach ($this->getHttpMethodOmissions() as $httpMethodOmissionNode) {
            $httpMethodOmissions[] = strtoupper($httpMethodOmissionNode->__toString());
        }

        // return the array with the HTTP method omissions
        return $httpMethodOmissions;
    }
577834
private function buildUrlParams(
        string $url,
        array $params
    ) {
        array_walk($params, function (&$value, $key) {
            $value = "$key=$value";
        });

        return $url.'?'.implode('&', $params);
    }
911884
protected function buildRequest($method, $url, $params = [])
    {
        if (count($params) > 0) {
            $url .= strpos($url, '?') === false ? '?' : '&';
            $url .= http_build_query($params);
        }
        return new Request($url, $method);
    }
993676
public function get($url, array $params = [], array $headers = [])
    {
        $url = $this->formatUrl($url, $url !== 'current/Me', $url == $this->nextUrl);

        try {
            $request = $this->createRequest('GET', $url, null, $params, $headers);
            $response = $this->client()->send($request);

            return $this->parseResponse($response, $url != $this->nextUrl);
        } catch (Exception $e) {
            $this->parseExceptionForErrorMessages($e);
        }
    }
1078329
public function fullUrl($url = false, $omitProtocol = false, $omitBaseUrl = false) {
        if (!$url) {
            $url = $this->view->url();
        }
        $fullUrl = new Garp_Util_FullUrl($url, $omitProtocol, $omitBaseUrl);
        return $fullUrl->__toString();
    }