Handles a Request, converting it to a Response.

@return Proem\Http\Response
547926
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        while ($route = $this->router->route($request)) {
            $module     = $route->getPayload()['module'];
            $controller = $route->getPayload()['controller'];
            $action     = $route->getPayload()['action'];
            $class      = str_replace(
                ['{:module}', '{:controller}'],
                [$module, $controller],
                $this->mapping
            );
            try {
                return $this->assetManager->resolve($class, ['invoke' => $action]);
            } catch (\LogicException $e) {
                $this->failures[] = ['route' => $route, 'exception' => $e];
            }
        }
    }
484998
public function handle()
    {
        try {
            $event = new BeforeProxyEvent($this->proxy_query);
            $this->event_dispatcher->dispatch('owsproxy.before_proxy', $event);
        } catch (\RuntimeException $e) {
            throw new HTTPStatus502Exception();
        }

        $browserResponse = parent::handle();

        if ($browserResponse->isOk()) {
            $event = new AfterProxyEvent($this->proxy_query, $browserResponse);
            $this->event_dispatcher->dispatch('owsproxy.after_proxy', $event);
        } else {
            // pass auth challenge down to client, but alter realm to make it
            // unique as it will be applied to this server as the auth
            // partition key!
            if (401 === $browserResponse->getStatusCode()) {
                $headers = $browserResponse->getHeaders();
                $needle = 'www-authenticate: basic realm="';
                foreach ($headers as $idx => &$header) {
                    $haystack = strtolower($header);
                    if (0 === strpos($haystack, $needle)) {
                        $origRealm = substr($header, strlen($needle), strlen($header) - strlen($needle) - 1);
                        $rawUrl = $this->proxy_query->getRowUrl(); // ;)

                        $scheme = empty($rawUrl["scheme"]) ? "http://" : $rawUrl["scheme"] . "://";
                        $host = $rawUrl["host"];
                        $port = empty($rawUrl["port"]) ? "" : ":" . $rawUrl["port"];
                        $path = empty($rawUrl["path"]) ? "" : $rawUrl["path"];
                        $server = $scheme . $host . $port . $path;
                        $realm = 'Server: ' . $server . ' - ' . $origRealm;
                        $header = 'WWW-Authenticate: Basic realm="' . $realm . '"';

                        $browserResponse->setHeaders($headers);
                        break;
                    }
                }
                return $browserResponse;
            }
            $message = null;
            if ($browserResponse->getReasonPhrase() !== null) {
                $rawUrl = $this->proxy_query->getRowUrl();
                $message = 'Server "' . $rawUrl['host'] . '" says: ' . $browserResponse->getReasonPhrase();
                throw new HTTPStatus502Exception($message);
            } else {
                throw new HTTPStatus502Exception();
            }
        }
        return $browserResponse;
    }
136566
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());

        $this->authorize($request, $entity);
        $this->hydrateEntity($entity, $request->getData());
        $this->validateEntity($entity);
        $this->repository()->getEntityManager()->flush();

        return $this->response()->resource($request,
            new Item($entity, $this->transformer())
        );
    }
298863
public function handler(): Response
    {
        $extension = Extension::findBy([
            'vendor' => $this->getParameter('vendor'),
            'package' => $this->getParameter('package')
        ]);
        if (!$extension) {
            throw new HttpForbiddenException();
        }
        $extension->uninstall();
        $this->log('info', 'Uninstall extension [' . $extension->getPackage() . ']');
        return response();
    }
1102076
public function handle()
    {
        // get information about the REST-request
        $this->get();

        if ($this->requestMethod === 'GET' && $this->typo3Cache->hasCacheEntry($this->url, $_GET)) {
            return $this->handleRequestByTypo3Cache();
        }

        // if no cache exist: restler should handle the request
        return parent::handle();
    }
405981
public function handleRequest()
    {
        // Create the request very early so the ResourceManagement has a chance to grab it:
        $request = Request::createFromEnvironment();
        $response = new Response();
        $this->componentContext = new ComponentContext($request, $response);

        $this->boot();
        $this->resolveDependencies();
        $response = $this->addPoweredByHeader($response);
        $this->componentContext->replaceHttpResponse($response);
        $baseUriSetting = $this->bootstrap->getObjectManager()->get(ConfigurationManager::class)->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow.http.baseUri');
        if (!empty($baseUriSetting)) {
            $baseUri = new Uri($baseUriSetting);
            $request = $request->withAttribute(Request::ATTRIBUTE_BASE_URI, $baseUri);
            $this->componentContext->replaceHttpRequest($request);
        }

        $this->baseComponentChain->handle($this->componentContext);
        $response = $this->baseComponentChain->getResponse();

        $response->send();

        $this->bootstrap->shutdown(Bootstrap::RUNLEVEL_RUNTIME);
        $this->exit->__invoke();
    }
976047
public function handle(Request $request)
	{
		// execute response
		$response = $this->next($request);

		// only do on json data
		if (!$response->isJson())
		{
			return $response;
		}

		// get the response content and json decode
		$content = json_decode($response->getContent());

		// get date keys from response options
		$this->dateKeys = array_merge(
			$this->dateKeys,
			$response->getTransformKeys('dates')
		);

		// make sure to handle array different then a single object
		if (is_array($content))
		{
			// loop through each item in array and covert dates
			foreach ($content as $key => $value)
			{
				$content[$key] = $this->convertDateKeysInObjects($value);
			}
		}
		else
		{
			// convert single object dates
			$content = $this->convertDateKeysInObjects($content);
		}

		// set the response content to modified content
		$response->setContent(json_encode($content));

		// return response
		return $response;
	}
424130
public function handleRequest($request)
    {
        list ($route, $params) = $request->resolve();
        $this->requestedRoute = $route;
        $result = $this->runAction($route, $params);
        if ($result instanceof Response) {
            return $result;
        } else {
            $response = $this->getResponse();
            $response->exitStatus = $result;

            return $response;
        }
    }
709450
public function handler(): Response
    {
        $response = [];
        $roles = [];
        $role_slugs = $this->request->get('roles', '');
        if (!$role_slugs) {
            $members = Member::all(['createdAt' => 'ASC']);
        } else {
            foreach (explode(',', $role_slugs) as $role_slug) {
                $roles[] = Role::findBy(['slug' => $role_slug]);
            }
            $members = Member::where(['role' => $roles], ['createdAt' => 'ASC']);
        }
        foreach ($members as $member) {
            $r = $member->getRole();
            $response[] = [
                'id' => $member->getId(),
                'username' => $member->getUsername(),
                'email' => $member->getEmail(),
                'phone' => $member->getPhone(),
                'name' => $member->getName(),
                'gender' => $member->getGender(),
                'role' => [
                    'slug' => $r->getSlug(),
                    'name' => $r->getName(),
                    'color' => $r->getColor(),
                    'icon' => $r->getIcon()
                ]
            ];
        }
        return response($response);
    }
336806
public function handler(): Response
    {
        $data = $this->validate([
            'email' => [
                new NotBlank(),
                new Email()
            ]
        ]);
        $member = Member::findBy($data);
        if ($member) {
            $this->log('info', '[' . $data['email'] . '] get password reset token');
            $token = (new PasswordResetToken())
                ->member($member)
                ->save();
            app()->dispatch(new VerifyTokenNeedsToBeSent($member, $token->getId()));
        } else {
            $this->log('info', '[' . $data['email'] . '] failed to get password reset token');
            sleep(mt_rand(1, 3)); // avoid judging status through time used
        }
        return response();
    }
777757
public function process()
    {
        // Check if we should verify the request
        if ($this->configuration->getUseAuthorization()) {
            if (
                $this->uri != '/token' &&
                $this->uri != '/authorize' &&
                !$this->tokenServer->verifyResourceRequest(\OAuth2\Request::createFromGlobals())
            ) {
                // Get the data as json and convert it to an array,
                // - so we can set our own response type.
                $data = $this->tokenServer->getResponse()->getResponseBody('json');
                $data = json_decode($data, true);

                // Set the response, status code and output content setting final output to true
                $this->response = $data;
                $this->statusCode = $this->tokenServer->getResponse()->getStatusCode();
                $this->output(true);
                return $this;
            }
        }

        try {
            // Handle OPTIONS requests
            if ($this->method == 'options') {
                $this->handleOptionsRequest();
            } else {
                // Execute the router
                $this->router->execute();
            }
        } catch (\Exception $e) {
            // Set the response and status code to error
            $this->response = ['error' => 1, 'message' => $e->getMessage()];
            $this->statusCode = 500;
        }

        // Output the response
        $this->output();
    }
766775
public function handler(): Response
    {
        $extension = Extension::findBy([
            'vendor' => $this->getParameter('vendor'),
            'package' => $this->getParameter('package')
        ]);
        if (!$extension) {
            throw new HttpForbiddenException();
        }
        if ($this->request->get('activation') === true) {
            $extension->activate();
            $this->log('info', 'Activate extension [' . $extension->getPackage() . ']');
        } else {
            $extension->deactivate();
            $this->log('info', 'Deactivate extension [' . $extension->getPackage() . ']');
        }
        return response();
    }
1361348
protected function handlePost() : HttpResponse
    {
        $fileName   = $this->getRequest()->extractFileName();
        $uploadType = self::UPLOAD_TYPE_NORMAL;

        if (empty($fileName)) {
            return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
        }

        if ( ! $this->verifyUploadSize()) {
            return $this->response->send(null, HttpResponse::HTTP_REQUEST_ENTITY_TOO_LARGE);
        }

        $uploadKey = $this->getUploadKey();
        $filePath  = $this->uploadDir . DIRECTORY_SEPARATOR . $fileName;

        if ($this->getRequest()->isFinal()) {
            return $this->handleConcatenation($fileName, $filePath);
        }

        if ($this->getRequest()->isPartial()) {
            $filePath   = $this->getPathForPartialUpload($uploadKey) . $fileName;
            $uploadType = self::UPLOAD_TYPE_PARTIAL;
        }

        $checksum = $this->getClientChecksum();
        $location = $this->getRequest()->url() . $this->getApiPath() . '/' . $uploadKey;

        $file = $this->buildFile([
            'name' => $fileName,
            'offset' => 0,
            'size' => $this->getRequest()->header('Upload-Length'),
            'file_path' => $filePath,
            'location' => $location,
        ])->setKey($uploadKey)->setChecksum($checksum);

        $this->cache->set($uploadKey, $file->details() + ['upload_type' => $uploadType]);

        $this->event()->dispatch(
            UploadCreated::NAME,
            new UploadCreated($file, $this->getRequest(), $this->getResponse())
        );

        return $this->response->send(
            null,
            HttpResponse::HTTP_CREATED,
            [
                'Location' => $location,
                'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            ]
        );
    }
214392
public function handle(Request $request)
    {
        $response = new Response();
        $response = $this->executePassiveActions($request, $response);
        $response = $this->executeAction($request, $response);

        if ($response->isClientError() || $response->isServerError()) {
            return $this->handleError($request, $response);
        }

        return $response;
    }
140111
public function process()
	{
		// Get this request's data.
		$this->parseRequest();

		// Perform logic.
		$this->execute();

		// Parse the result of our business logic.
		$this->parseResult();

		// Build the Response utilizing status, type, body, etc.
		$this->buildResponse();

		// Build the broadcasted value.
		$this->buildBroadcast();

		// Broadcast the result to listeners.
		$this->push();

		// Finally, return the Response.
		return $this->respond();
	}
555118
public function handleOptionsRequest()
    {
        // Generate the "Allow" header
        $allow = '';
        foreach ($this->router->getMethodsByRoute($this->uri) as $method) {
            $allow .= strtoupper($method) . ',';
        }
        $allow = substr($allow, 0, strlen($allow) - 1);
        header('Allow: ' . $allow);
        $this->setResponse('');
    }
902153
protected function postRequest()
    {
        $response = $this->client->post($this->buildUrl(),
            [
                'auth'    => $this->getAuth(),
                'json'    => $this->getBody(),
                'headers' => [
                    'Accept' => 'application/json',
                ],
            ]);

        if ($response->getStatusCode() != 201 && $response->getStatusCode() != 200) {
            throw new \Exception('Unable to request from API. HTTP Error: '.$response->getStatusCode());
        }

        return $response;
    }