Do the call.

@param  resource   $http
@return string
@throws CallFailed
769157
private function execute(&$http)
    {
        $raw_response = curl_exec($http);

        if ($raw_response === false) {
            $error_code = curl_errno($http);
            $error_message = curl_error($http);

            curl_close($http);

            throw new CallFailed($error_code, $raw_response, null, $error_message);
        } else {
            $response = new Response($http, $raw_response, $this->response_headers);
            curl_close($http);

            return $response;
        }
    }
1367228
protected function onFailure(RequestInterface $request)
    {
        return function ($reason) use ($request) {
            if ($this->enabled) {
                $response = null;

                if ($reason instanceof RequestException) {
                    $response = $reason->getResponse();
                }

                $this->log($request, $response);
            }

            return Promise\rejection_for($reason);
        };
    }
1120438
public function execute(HTTPRequest $request, callable $callback, $flush = false)
    {
        try {
            return $this->callMiddleware($request, function ($request) use ($callback, $flush) {
                // Pre-request boot
                $this->getKernel()->boot($flush);
                return call_user_func($callback, $request);
            });
        } catch (HTTPResponse_Exception $ex) {
            return $ex->getResponse();
        } finally {
            $this->getKernel()->shutdown();
        }
    }
579909
private function handle($request)
    {
        $found = $this->fileMap->render($request->getPathToMatch());
        if (empty($found)) {
            return null;
        }
        if (is_resource($found[0])) {
            return $request->respond()->asFileContents($found[0], $found[1]);
        }
        if (is_string($found[0])) {
            return $request->respond()->asContents($found[0]);
        }
        return null;
    }
1241426
public function handle(Request $request)
	{
		// execute response
		$response = $this->next($request);

		// check for presence of callback param
		// if we have one lets replace response content with a function executing the 
		// current response content
		if ($callback = $request->getVar('callback', null))
		{
			$response->headers->set('content-type', 'application/javascript');
			$response->setContent(sprintf('%s(%s);', $callback, $response->getContent()));
		}

		// return response
		return $response;
	}
1287795
protected function fail($message, $http_status = 500)
    {
        if (!empty($this->options['fail_exception'])) {
            throw new Exception($message, $http_status);
        }

        if ($http_status === 500) {
            trigger_error($message, E_USER_WARNING);
        }

        if ($this->returnType === 'jsonp') {
            echo $_REQUEST['callback'] . "(" . json_encode(['error' => $message]) . ", $http_status);";
            exit();
        }

        if ($this->returnType === 'redirect') {
            $url = $_REQUEST['return_url'] . '?sso_error=' . $message;
            header("Location: $url", true, 307);
            echo "You're being redirected to <a href='{$url}'>$url</a>";
            exit();
        }

        http_response_code($http_status);
        header('Content-type: application/json; charset=UTF-8');

        echo json_encode(['error' => $message]);
        exit();
    }
779787
public function dispatching(HttpListener $request):int
    {
        self::$runtime_parameters = $request;
        $apps = AppTools::registerApps();
        $bapps = AppTools::registerBaseApps();
        $great = false;

        if ($this->isComponentCall($bapps, $request)) {
            return (1);
        }
        
        $values = AppTools::getSimpleAppFormat($apps);
        foreach ($values as $one => $def) {
            if ($great) {
                return (1);
            }
            if ($def["value"]["enabled"] == "no") {
                continue;
            }
            $rt = new Routing($def['name'], $def['value']['prefix']);
            if ($rt->routingRegister() == true) {
                $callback = FrameworkTools::manage($request, $rt->routes());
                if ($callback != null) {
                    (AppConfig::getInstance($def['name']))->checkRequirements();
                    Routing::checkRouteMatchesMethod($callback, strtoupper($request->getMethod()));
                    $method = $callback['method'];
                    $controller = $callback['controller'];
                    $defname = $def['name'];
                    $master = "\\$defname\\Masters\\{$controller}Master";
                    $call = new FrameworkReflection();
                    FEnv::set("app.call", $def['name']);
                    FEnv::set("app.is_components", false);
                    Locale::applyLocale($callback["locale"] ?? null);
                    if (isset($callback['pval'])) {
                        if (isset($callback['r_parameters']) && count($callback['r_parameters']) > 0) {
                            $callback['pval'] = $rt->checkParametersTypeURI(
                                $callback['pval'],
                                $callback['r_parameters'],
                                $callback["routename"]
                            );
                        }
                        $rscall = $call->__named($master, $method, $callback['pval']);
                    } else {
                        $rscall =  $call->__named($master, $method);
                    }
                    if (!($rscall instanceof Renderer)) {
                        $ac_called = FEnv::get("app.activity_called");
                        throw new Server500(new \ArrayObject(
                            array("explain" => "The activity {".$ac_called['method'].
                                "} result in object {".$ac_called['class'].
                                "} must be a Renderer : ".ucfirst(gettype($rscall))." is given", "solution" =>
                            "Return a Renderer instance in this activity")
                        ));
                    }
                    $great = true;
                    new Access200();
                    $rscall->pushRender();
                }
            } else {
                throw new Server500(new \ArrayObject(array("explain" => "Router register failed  ", "solution" =>
                    "Please check your app configuration")));
            }
        }
        if ($great == false) {
            throw new Server404(new \ArrayObject(array("solution" => "Please check your URI")));
        }

        return (1);
    }
283656
public function failureAction(Request $request)
    {
        $orderId = $this->getOrderId($request);

        $failureRoute = $this
            ->redirectionRoutes
            ->getRedirectionRoute('failure');

        $redirectUrl = $this
            ->urlGenerator
            ->generate(
                $failureRoute->getRoute(),
                $failureRoute->getRouteAttributes(
                    $orderId
                )
            );

        return new RedirectResponse($redirectUrl);
    }
197341
public function handle(HttpRequest $request)
    {
        $routeClass = Loader::load('route');

        $route = new $routeClass($this->route, $request->method());
        $controllerClassMethod = $route->resolve();
        if (false === $controllerClassMethod) {
            throw new Exception('Can\t resolve route.'); // TODO: Change to 404 response
        }

        $controllerClass = array_shift($controllerClassMethod);
        $controllerMethod = array_shift($controllerClassMethod);

        $controller = new $controllerClass($request);
        if (method_exists($controller, $controllerMethod)) {
            $output = call_user_func_array(array($controller, $controllerMethod), $route->get());
        } else {
            throw new ApplicationException(sprintf('Method "%s" doesn\'t exists in class "%s".', $method, $controllerClass)); // TODO: Change to 404 response
        }

        if ($request->isAjax()) {
            return json_encode($output);
        } else {
            return $output;
        }
    }
420102
public function output()
    {
        // Check that the method for this HTTP request method exists.
        $methodName = 'http_' . $this->request->httpMethod();
        if (method_exists($this, $methodName)) {
            // Execute the requested Resource instance's method that 
            // corresponds with the requested HTTP method.
            return $this->$methodName();
        } else {
            // The Resource instance didn't define a method for the request's 
            // HTTP method - return a 405.
            return $this->response->send(
                    405,
                    'The requested resource does not support the HTTP method'.
                    ' "' . $this->request->httpMethod() . '".'
            );
        }   
    }
14609
public function execute($request)
    {
        $result = $request->authHeaders()->send();

        if ($result->status === self::API_STATUS_FAIL) {
            throw new Exception('Error: '.$result->error);
        }

        return $result;
    }
248673
public function doRequest(Request $request)
	{
		$response = $this->getIo()->call($request);
		if (!$response) {
			// cURL error
			throw new HttpException('Request failed');
		} else if (isset($response->data['errors'])) {
			// GoPay errors
			$error = $response->data['errors'][0];
			throw new HttpException(HttpException::format($error), $error->error_code);
		}

		return $response;
	}
572714
protected function detectMethod(HttpRequest $request)
	{
		$requestMethod = $request->getMethod();
		if ($requestMethod !== 'POST') {
			return $request->getMethod();
		}

		$method = $request->getHeader(self::HTTP_HEADER_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		$method = $request->getQuery(self::QUERY_PARAM_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		return $requestMethod;
	}
1176583
public function callback(HTTPRequest $request)
    {
        $session = $request->getSession();

        if (!$this->validateState($request)) {
            $session->clear('oauth2');
            $this->httpError(400, 'Invalid session state.');
            return null;
        }

        $providerName = $session->get('oauth2.provider');
        /** @var ProviderFactory $providerFactory */
        $providerFactory = Injector::inst()->get(ProviderFactory::class);
        $provider = $providerFactory->getProvider($providerName);
        $returnUrl = $this->getReturnUrl();

        try {
            $accessToken = $provider->getAccessToken('authorization_code', [
                'code' => $request->getVar('code')
            ]);

            $handlers = $this->getHandlersForContext($session->get('oauth2.context'));

            // Run handlers to process the token
            $results = [];
            foreach ($handlers as $handlerConfig) {
                $handler = Injector::inst()->create($handlerConfig['class']);
                $results[] = $handler->handleToken($accessToken, $provider);
            }

            // Handlers may return response objects
            foreach ($results as $result) {
                if ($result instanceof HTTPResponse) {
                    $session->clear('oauth2');

                    // If the response is redirecting to the login page (e.g. on Security::permissionFailure()),
                    // update the BackURL so it doesn't point to /oauth/callback/
                    if ($result->isRedirect()) {
                        $location = $result->getHeader('location');
                        $relativeLocation = Director::makeRelative($location);

                        // If the URL begins Security/login and a BackURL parameter is set...
                        if (
                            strpos($relativeLocation, Security::config()->uninherited('login_url')) === 0
                            && strpos($relativeLocation, 'BackURL') !== -1
                        ) {
                            $session->set('BackURL', $returnUrl);
                            $location = HTTP::setGetVar('BackURL', $returnUrl, $location);
                            $result->addHeader('location', $location);
                        }
                    }
                    
                    return $result;
                }
            }
        } catch (IdentityProviderException $e) {
            /** @var LoggerInterface $logger */
            $logger = Injector::inst()->get(LoggerInterface::class . '.oauth');
            $logger->error('OAuth IdentityProviderException: ' . $e->getMessage());
            $this->httpError(400, 'Invalid access token.');
            return null;
        } catch (Exception $e) {
            /** @var LoggerInterface $logger */
            $logger = Injector::inst()->get(LoggerInterface::class . '.oauth');
            $logger->error('OAuth Exception: ' . $e->getMessage());
            $this->httpError(400, $e->getMessage());
            return null;
        } finally {
            $session->clear('oauth2');
        }

        return $this->redirect($returnUrl);
    }
291675
protected function handleRouting(HttpRequest $request)
    {
        $this->router = $this->serviceManager->get('Router');
        $this->router->warmUp($this->getCacheDir());

        try {
            // Lets load up our router and match the appropriate route
            $parameters = $this->router->matchRequest($request);
            if (!empty($parameters)) {
                if (null !== $this->logger) {
                    $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->router->parametersToString($parameters)));
                }
            }
        } catch (ResourceNotFoundException $e) {
            $routeUri = $this->router->generate('Framework_404');
            $parameters = $this->router->matchRequest($request::create($routeUri));
        } catch (\Exception $e) {
            throw $e;
        }

        $parameters['_route_params'] = $parameters;

        return $parameters;
    }
682
public function callback($request)
    {
        // If post data exists, process. Otherwise provide error
        if ($this->payment_handler === null) {
            // Redirect to error page
            return $this->redirect(Controller::join_links(
                Director::BaseURL(),
                $this->config()->url_segment,
                'complete',
                'error'
            ));
        }
        
        // Hand the request over to the payment handler
        return $this
            ->payment_handler
            ->handleRequest($request, $this->model);
    }
576154
public function getExceptionForFailedRequest(RequestInterface $request)
    {
        $oid = spl_object_hash($request);

        return isset($this->exceptionForRequest[$oid]) ? $this->exceptionForRequest[$oid] : null;
    }