Execute the request for this resource.

@param \mod_lti\local\ltiservice\response $response  Response object for this request.
763013
public function execute($response) {
        global $DB;

        $params = $this->parse_template();
        $linkid = $params['link_id'];
        $role = optional_param('role', '', PARAM_TEXT);
        $limitnum = optional_param('limit', 0, PARAM_INT);
        $limitfrom = optional_param('from', 0, PARAM_INT);

        if ($limitnum <= 0) {
            $limitfrom = 0;
        }

        if (empty($linkid)) {
            $response->set_code(404);
            return;
        }
        if (!($lti = $DB->get_record('lti', array('id' => $linkid), 'id,course,typeid,servicesalt', IGNORE_MISSING))) {
            $response->set_code(404);
            return;
        }
        $tool = $DB->get_record('lti_types', array('id' => $lti->typeid));
        if ($tool->toolproxyid == 0) { // We wil use the same permission for this and contextmembers.
            if (!$this->check_type($lti->typeid, $lti->course, 'ToolProxyBinding.memberships.url:get', null)) {
                $response->set_code(403);
                return;
            }
        } else {
            $toolproxy = $DB->get_record('lti_tool_proxies', array('id' => $tool->toolproxyid));
            if (!$this->check_tool_proxy($toolproxy->guid, $response->get_request_data())) {
                $response->set_code(403);
                return;
            }
        }
        if (!($course = $DB->get_record('course', array('id' => $lti->course), 'id', IGNORE_MISSING))) {
            $response->set_code(404);
            return;
        }
        if (!($context = \context_course::instance($lti->course))) {
            $response->set_code(404);
            return;
        }
        $modinfo = get_fast_modinfo($course);
        $cm = get_coursemodule_from_instance('lti', $linkid, $lti->course, false, MUST_EXIST);
        $cm = $modinfo->get_cm($cm->id);
        $info = new info_module($cm);
        if ($info->is_available_for_all()) {
            $info = null;
        }
        $json = memberships::get_users_json($this, $context, $lti->course, $tool, $role, $limitfrom, $limitnum, $lti, $info);

        $response->set_content_type($this->formats[0]);
        $response->set_body($json);
    }
787572
public function route(string $uri, Response $response) : void
    {
        $this->reroutes ++;
        if ($this->reroutes > 10) {
            FW()->log->critical('The request for ' . $uri . ' has redirected too many times!');
            $response->setStatusCode(508);
            return;
        }
        // Process the URI
        $url_array = $this->processURL($uri);
        // Extract the ISO locale code from the beginning
        $this->extractLocale($url_array, $response);
        // Remove the extension from the filename
        $filename = array_pop($url_array);
        $extension = pathinfo($filename, PATHINFO_EXTENSION);
        $filename = pathinfo($filename, PATHINFO_FILENAME);
        $url_array[] = $filename;
        // Save the resolved path and extension
        $this->path = implode('/', $url_array);
        FW()->log->debug('Resolved Path: ' . $this->path);
        $this->extension = $extension;
        // Get the module and action if provided. TODO: This needs a try/catch
        $variables = $this->matchRoute($url_array);
        $response->resetMCAValues();
        if (isset($variables['module'])) {
            $response->setModule($variables['module']);
            unset($variables['module']);
        }
        if (isset($variables['controller'])) {
            $response->setController($variables['controller']);
            unset($variables['controller']);
        }
        if (isset($variables['action'])) {
            $response->setAction($variables['action']);
            unset($variables['action']);
        }
        // Store the variables for retrieval
        if (count($variables) > 0) {
            $response->setVariables($variables);
        }
    }
232376
public function prepareForResponse(Response $response) {
		if ('application/json' == $response->getRequest()->getAcceptRange()
	               ->bestMatch(['text/html', 'application/json'])) {
            	$this->payload = new JhtmlJsonPayload($this->additionalAttrs);
               	$this->payload->applyRedirect($this->directive, $this->httpLocation, $this->jhtmlExec);
			$this->payload->prepareForResponse($response);
	        return;
	    } 
	    
		$this->payload = new Redirect($this->httpLocation);
		$this->payload->prepareForResponse($response);
	}
1130948
public function call(Request $request, Response $response) : Response {

		return call_user_func($this->callable, $request, $response, $this->slugs);

	}
439684
public function setResponse($response)
    {
        $xml = simplexml_load_string($response);
        if (!empty($xml->error)) {
            $this->message = (string) $xml->error;
        }
    }
683651
protected function response(Response $response)
    {
        return $this->response->create(
            (string)$response->getContent(),
            $response->getStatusCode(),
            (array)$response->headers->all()
        );
    }
1320686
protected function setNeededAction(Response $response) {
        if ($response->hasHtml())
        {
            $response->setNeededAction(Response::NEEDED_SHOW_HTML);
        }
        elseif ($response->isProcessing())
        {
            $response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
        }
    }
1071247
public function next(Request $request, Response $response, $next)
    {
        $response->setContentType('text/json');
        $next($request, $response);
    }
978334
public function respond( ResponseInterface $response ) {
		if ( ! headers_sent() ) {
			$this->sendHeaders( $response );
		}
		$this->sendBody( $response );
	}
482555
public function launch(Request $request, Response $response)
    {
        if (count($this->routes) === 0) {
            throw new \RuntimeException("No routes defined");
        }

        $this->uri = $request->httpRequest->getPath();

        if ($this->uri = null) {
            $this->uri = "/";
        }

        $request->on('end', function () use (&$request, &$response) {
            $this->matchRoutes($request, $response);  
        });

        $request->on('error', function ($error) use (&$request, &$response) {
            $this->emit('error', [$request, $response, $error]);
        });

        $request->parseData();
    }
837725
public function run(Callable $next, Request $request, Response $response)
    {
        $container  = Container::getInstance();
        $parameters = array_merge([
            "request"   => $request,
            "response"  => $response,
            "next"      => $next
        ], $request->getData());

        try {
            $container->call($this->action, $parameters);
            $this->emit('after', [$request, $response, $this]);
        } catch (\Exception $e) {
            $this->emit('error', [$request, $response, $e->getMessage()]);
        }
    }
1034392
public function respond($type = 'json', array $response = array()) {
        if ($response) {
            $response = $response + array(
                'success' => false,
                'data' => '',
                'code' => null
            );

            $this->response($response['success'], $response['data'], $response['code']);
        }

        if ($type === 'html') {
            $this->RequestHandler->renderAs($this->controller, 'ajax');

        } else {
            $this->RequestHandler->respondAs($type);
            $this->controller->autoLayout = false;
            $this->controller->autoRender = false;

            echo $this->_format($type);
        }
    }
613434
public function run(HttpRequest $request = null, HttpResponse $response = null)
    {
        if (false === $this->booted) {
            $this->boot();
        }

        if (null === $request) {
            $request = HttpRequest::createFromGlobals();
        }

        if (null === $response) {
            $response = new HttpResponse();
        }

        // Create a copy of request, as it's by-ref passed into $this->dispatch() and gets modified.
        $cleanRequest = clone $request;
        try {
            $response = $this->dispatch($request, $response);
        } catch (ResourceNotFoundException $e) {

            if($this->symfonyKernel === null) {
                throw $e;
            }
            $response = $this->symfonyKernel->handle($cleanRequest);
        }


        $response->send();

        return $response;
    }
211000
protected function handleResponse(Response $response)
    {
        $statusCode = $response->getStatusCode();

        switch ($statusCode) {
            case 401:
                $response = $this->processNotAuthorized();
                break;
        }

        return $response;
    }
771593
public function afterSend($response)
    {
        $this->client->afterSend($this, $response);

        $event = new RequestEvent();
        $event->request = $this;
        $event->response = $response;
        $this->trigger(self::EVENT_AFTER_SEND, $event);
    }
1122394
public function process(\BearFramework\App\Response $response): void
    {
        $response->content = $this->app->components->process($response->content);
    }
1277323
public function execute()
    {
        $this->response = curl_exec($this->curlHandle);

        $this->checkForErrors();

        list($this->responseHeaders, $this->responseBody) = explode("\r\n\r\n", $this->response, 2);
    }