Indica si el usuario logueado tiene acceso a un url y request method
@param Request $request
@param string $url
@param string $method
@return boolean
503264
public function userHasAccessToUrl($request, $url, $method){
        //Tipo por defecto
        $userProfile= $this->getUserProfiles($request);
        $maps= FALSE;
        if(is_array($userProfile)){
            $maps= $this->profilesHasAccessToUrl($userProfile, $url, $method);
        }else{
            $maps= $this->profileHasAccessToUrl($userProfile, $url, $method);
        }
        return $maps;
    }
1300472
public function request( $method, $url, $params=null )
    {
        if( $params === null )
            $params = array();

        list( $rbody, $rcode ) = $this->requestRaw( $method, $url, $params );

        $resp = $this->interpretResponse( $rbody, $rcode, $method );

        return $resp['data'];
    }
1243698
public function isAjaxRequest(Request $request)
    {
        $result = false;
        $requestedWith = $request->server->get('HTTP_X_REQUESTED_WITH');
        if (is_string($requestedWith) && strcasecmp($requestedWith, 'XMLHttpRequest') === 0) {
            $result = true;
        }

        return $result;
    }
1071508
public function createRequest($method, $uri)
    {
        $uri = \is_string($uri)
            ? Uri::create($uri)
            : $uri;

        return new Request($method, $uri);
    }
163204
public static function useHttps(Request $request): bool
    {
        $checks = [
            'HTTPS',
            'SERVER_PORT',
            'HTTP_X_FORWARDED_SSL',
            'HTTP_X_FORWARDED_PROTO',
        ];
        foreach ($checks as $check) {
            if (call_user_func([__CLASS__, sprintf('check%s', Text::toCamelCase($check))], $request)) {
                return true;
            }
        }

        return false;
    }
717272
protected function request($method, $url, $parameters = array())
    {
        Logger::get()->debug('HTTP: starting request...');
        $headers = $this->headers;

        // Add accepted content type header.
        $headers[] = 'Content-Type: ' . $this->contentType;
        $headers[] = 'Accept: ' . $this->acceptedContentType;

        $handler = curl_init();

        if (!is_null($this->user)) {
            curl_setopt($handler, CURLOPT_USERPWD, $this->user . ':' . $this->password);
        }

        Logger::get()->debug('HTTP: method is ' . $method);
        switch ($method) {
            case self::METHOD_DELETE:
                curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters));
                curl_setopt($handler, CURLOPT_CUSTOMREQUEST, self::DELETE);
                break;
            case self::METHOD_POST:
                curl_setopt($handler, CURLOPT_URL, $url);
                curl_setopt($handler, CURLOPT_POST, true);
                curl_setopt($handler, CURLOPT_POSTFIELDS, $parameters);
                break;
            case self::METHOD_GET:
                curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters));
                break;
        }

        curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($handler, CURLOPT_HTTPHEADER, $headers);
        Logger::get()->debug('HTTP: headers set.');

        // Send the request to the server.
        Logger::get()->debug("HTTP: requesting $url...");
        $output = curl_exec($handler);
        $errNo = curl_errno($handler);
        $error = curl_error($handler);
        // Obtain the status.
        Logger::get()->debug('HTTP: Done. Getting status...');
        $status = curl_getinfo($handler, CURLINFO_HTTP_CODE);
        // The handler is no longer needed.
        curl_close($handler);
        Logger::get()->debug('HTTP: request finished.');

        if ($errNo) {
            throw new Exception('HTTP: cURL failed: ' . $error, $errNo);
        }

        // If cURL had no errors itself, then there is an HTTP response.
        switch ($status) {
            case self::STATUS_OK:
            case self::STATUS_CREATED:
            case self::STATUS_ACCEPTED:
            case self::STATUS_NO_CONTENT:
                return $output;
            default:
                throw new Http\Exception("HTTP {$status}", $status);
        }
    }
84787
protected function getMatchingUrlFragment(Request $request, $currentUrlFragment = "")
    {
        if ($currentUrlFragment[strlen($currentUrlFragment) - 1] != "/") {
            $currentUrlFragment .= "/";
        }

        if (stripos($currentUrlFragment, $this->url) === 0) {
            return $this->url;
        }

        return false;
    }
126030
protected function execute($request_method, $url, $parameters = null)
	{
		$extra_options = array(
			CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
			CURLOPT_USERPWD => $this->_apiUsername . ':' . $this->_apiKey,
		);

		$url = 'https://www.browserstack.com/automate/' . $url;

		list($raw_results,) = $this->_curlService->execute($request_method, $url, $parameters, $extra_options);

		return json_decode($raw_results, true);
	}
956214
public function handle(Request $request, string $method = self::HTTP_POST): bool
    {
        if (!$request->isMethod($method)) {
            return false;
        }

        if ($request->request->has('csrf_token')) {
            $session = new Session();

            if ($session->get('csrf_token') !== $request->request->get('csrf_token')) {
                throw new InvalidCsrfTokenException();
            }

            $request->request->remove('csrf_token');
        }

        $this->dataCollection = array_merge($request->request->all(), $request->files->all());

        return true;
    }
294599
public function match($URL, $method='get'){
      $method = strtolower($method);

      // * is an http method wildcard
      if (empty($this->methods[$method]) && empty($this->methods['*'])) return false;

      return (bool) (
        $this->dynamic
           ? preg_match($this->matcher_pattern, '/'.trim($URL,'/'))
           : rtrim($URL,'/') == rtrim($this->pattern,'/')
      );
    }
1219259
public static function createRequest($method, $uri)
    {
        if (! static::$requestFactory) {
            static::$requestFactory = new RequestFactory();
        }

        return static::$requestFactory->createRequest($method, $uri);
    }
423704
public function match($uri = null, $method = null)
    {
        $context = $this->_context;

        $uri = $uri ?: $this->getRewriteUri();

        if ($method === null) {
            $method = $this->request->getServer('REQUEST_METHOD');
        }

        $context->controller = null;
        $context->action = null;
        $context->params = [];

        $context->matched = false;

        if ($this->_prefix) {
            if (strpos($uri, $this->_prefix) === 0) {
                $handledUri = substr($uri, strlen($this->_prefix)) ?: '/';
            } else {
                $handledUri = false;
            }
        } else {
            $handledUri = $uri;
        }

        $area = null;
        $routes = $this->_simple_routes;
        if ($handledUri === false) {
            $parts = false;
        } elseif (isset($routes[$method][$handledUri])) {
            $parts = $routes[$method][$handledUri]->match($handledUri, $method);
        } elseif (isset($routes[''][$handledUri])) {
            $parts = $routes[''][$handledUri]->match($handledUri, $method);
        } else {
            $parts = false;
            $routes = $this->_regex_routes;
            for ($i = count($routes) - 1; $i >= 0; $i--) {
                $route = $routes[$i];
                if (($parts = $route->match($handledUri, $method)) !== false) {
                    if ($handledUri !== '/' && $this->_areas) {
                        if (($pos = strpos($handledUri, '/', 1)) === false) {
                            $area = Text::camelize(substr($handledUri, 1));
                        } else {
                            $area = Text::camelize(substr($handledUri, 1, $pos - 1));
                        }

                        if (!in_array($area, $this->_areas, true)) {
                            $area = null;
                        }
                    }
                    break;
                }
            }

            if ($parts === false) {
                if ($handledUri !== '/' && $this->_areas) {
                    if (($pos = strpos($handledUri, '/', 1)) !== false) {
                        $area = Text::camelize(substr($handledUri, 1, $pos - 1));
                        if (in_array($area, $this->_areas, true)) {
                            $handledUri = substr($handledUri, $pos);
                        } else {
                            $area = null;
                        }
                    } else {
                        $area = Text::camelize(substr($handledUri, 1));
                        if (in_array($area, $this->_areas, true)) {
                            $handledUri = '/';
                        } else {
                            $area = null;
                        }
                    }
                }

                $handledUri = $handledUri === '/' ? '/' : rtrim($handledUri, '/');
                $parts = $this->_default_route->match($handledUri, $method);
            }
        }

        if ($parts === false) {
            return false;
        }

        $context->matched = true;

        if ($area) {
            $context->area = $area;
        } elseif (isset($parts['area'])) {
            $context->area = $parts['area'];
        }

        $context->controller = $parts['controller'];
        $context->action = $parts['action'];
        $context->params = isset($parts['params']) ? $parts['params'] : [];

        return $context;
    }
18747
protected function request($url, $method = 'GET', array $params = [])
    {
        $url = $this->sanitizeQuery($url);

        $response = $this->client->request($method, $url, $params);

        if (is_array($response) && isset($response['paging'])) {
            $response = $this->injectPager($response, $method, $url, $params);
        }

        return $response;
    }
319815
protected function getRequest($method, $url) {
		$this->queryParams = array();
		
		$request = \Httpful\Request::$method($url);
		$request->sendsJson();
		$request->expectsJson();
		$request->addHeader('User-Agent', $this->identity);

		$ip = $this->getClientIp();

		if ($ip)
			$request->addHeader('Client-IP', $ip);
		
		return $request;
	}
667809
private function performRequest($method, $url, $options) {

        try {
            switch ($method) {
                case 'GET':
                    return json_decode($this->client->get($url, $options)->getBody(), true);
                case 'POST':
                    return json_decode($this->client->post($url, $options)->getBody(), true);
                case 'PUT':
                    return json_decode($this->client->put($url, $options)->getBody(), true);
                case 'DELETE':
                    return json_decode($this->client->delete($url, $options)->getBody(), true);
                default:
                    return null;
            }
        } catch (RequestException $e) {
            throw ApiException::create($e);
        }
    }
815527
public function match($method, $url)
	{
		$params = array();

		foreach ($this->routes as $name => $route)
		{
			if ($route->isMatch($method, $url))
			{
				$params = $route->getMatchedParams();
				break;
			}
		}

		return $params;
	}
1089375
public function request($url, $method = self::GET, $params = array(), $options = array())
    {
        if ($this->authorizer_access_token) {
            $url .= (stripos($url, '?') ? '&' : '?') . 'access_token=' . $this->authorizer_access_token;
        }

        if ($this->component_access_token) {
            $url .= (stripos($url, '?') ? '&' : '?') . 'component_access_token=' . $this->component_access_token;
        }

        $method = strtoupper($method);

        if ($this->json) {
            $options['json'] = true;
        }

        $response = parent::request($url, $method, $params, $options);

        $this->json = false;

        if (empty($response['data'])) {
            throw new Exception('服务器无响应');
        }

        // 文本或者json
        $textMIME = '~application/json|text/plain~i';

        $contents = JSON::decode($response['data'], true);

        // while the response is an invalid JSON structure, returned the source data
        if (!preg_match($textMIME,
                $response['content_type']) || (JSON_ERROR_NONE !== json_last_error() && false === $contents)
        ) {
            return $response['data'];
        }

        if (isset($contents['errcode']) && 0 !== $contents['errcode']) {
            if (empty($contents['errmsg'])) {
                $contents['errmsg'] = 'Unknown';
            }

            throw new Exception("[{$contents['errcode']}] " . $contents['errmsg'], $contents['errcode']);
        }

        if ($contents === array('errcode' => '0', 'errmsg' => 'ok')) {
            return true;
        }

        return $contents;
    }