handle the request

@return Response
@throws HttpUnauthorizedException
519565
public function handler(): Response
    {
        $this->auth(null);
        $data = $this->validate([
            'username' => [
                new NotBlank()
            ],
            'password' => [
                new NotBlank()
            ]
        ]);
        $member = Member::search($data['username']);
        if (!$member) {
            throw new HttpUnauthorizedException();
        }
        if (password_verify($data['password'], $member->getPassword())) {
            $this->auth($member);
            $this->log('info', 'Login successfully');
            return response();
        } else {
            $this->log('info', 'Login failed');
            throw new HttpUnauthorizedException();
        }
    }
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();
    }
1198798
public function handler(): Response
    {
        $data = $this->validate([
            'role_id' => [
                new NotBlank()
            ],
            'permission' => [
                new NotBlank()
            ],
            'value' => []
        ]);
        $role = Role::find($data['role_id']);
        if (!$role) {
            throw new HttpForbiddenException();
        }
        $attr = [
            'role' => $role,
            'permission' => $data['permission']
        ];
        if ($data['value'] === true) {
            (new Permission($attr))->save();
            $this->log('info', 'Add permission [' . $data['permission'] . '] of role [' . $role->getSlug() . ']');
        } else {
            $permission = Permission::findBy($attr);
            if (!$permission) {
                throw new HttpForbiddenException();
            }
            $permission->delete(true);
            $this->log('info', 'Delete permission [' . $data['permission'] . '] of role [' . $role->getSlug() . ']');
        }
        return response();
    }
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;
    }
14885
public function handler(): Response
    {
        $mailer = Mailer::find($this->getParameter('id'));
        if (!$mailer) {
            throw new HttpForbiddenException();
        }
        foreach (Mailer::all() as $m) {
            $m->default(false)->save();
        }
        $mailer->default(true)->save();
        $this->log('info', 'Set mailer [' . $mailer->getSender() . '] as default');
        return response();
    }
1058375
public function handler(): Response
    {
        $data = $this->validate([
            'email' => [
                new Email()
            ],
            'phone' => []
        ]);
        $member = Member::search($this->getParameter('username'));
        if (!$member) {
            throw new HttpNotFoundException();
        }
        $member->update($data);
        $this->log('info', 'Update member [' . $member->getUsername() . ']');
        return response();
    }
844508
public function handler(): Response
    {
        $response = [];
        foreach (Bulletin::all() as $bulletin) {
            $response[] = [
                'id' => $bulletin->getId(),
                'createdAt' => $bulletin->getCreatedAt()->getTimestamp(),
                'title' => $bulletin->getTitle(),
                'abstract' => $bulletin->getAbstract(),
                'isDraft' => $bulletin->isDraft(),
                'statistics' => $bulletin->getStatistics()
            ];
        }
        return response($response);
    }
185621
public function handleRequest()
    {
        list($route, $target) = $this->bootForRequest();

        $response = $this->runRequest($route, $target);

        $this->sendResponse($response);

        $this->terminateRequest();
    }
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();
    }
997014
public function handleRequest()
    {
        $request = $this->prepareRequest();
        $version = $request['version'];
        $queryConfiguration = $request['queryConfiguration'];

        $data = $this->provider->process();
        return $version->createResponse($data, $queryConfiguration, $this->columnConfigurations);
    }
1138903
protected function handleError()
    {
        $okStatus = array(
            100, 200, 201,
        );
        $messages = array(
            401 => 'Authorization required',
            403 => 'Forbidden request',
            404 => 'Not found',
            406 => 'Not accepted',
            422 => 'Unprocessable entity',
            500 => 'Internal server error',
            501 => 'Method not implemented',
        );

        if (isset($messages[$this->httpStatus])) {
            throw new HttpStatusException($messages[$this->httpStatus], $this->httpStatus);
        }
        if (!in_array($this->httpStatus, $okStatus)) {
            throw new UnknownHttpStatusException('Unknown http status: ' . $this->httpStatus);
        }
    }
652856
public function handle()
    {
        if (! $this->is_ajax_request()) {
            return Handler::DONE;
        }

        $response = [
            'success' => false,
            'data'    => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()),
        ];

        if (Misc::canSendHeaders()) {
            \header('Content-Type: application/json; charset=' . get_option('blog_charset'));
        }

        echo wp_json_encode($response, JSON_PRETTY_PRINT);

        return Handler::QUIT;
    }
1060258
public function exec(): Response
    {
        $url = $this->getUrl();

        $ch = curl_init($url);

        foreach ($this->getCurlOptions() as $option => $value) {
            // iterating it so we have all options applied in given order
            curl_setopt($ch, $option, $value);
        }

        $body = curl_exec($ch);

        if (curl_errno($ch)) {
            throw new HttpException(curl_error($ch));
        }

        return new Response($ch, $body, $this);
    }
416082
protected function handlePatch() : HttpResponse
    {
        $uploadKey = $this->request->key();

        if ( ! $meta = $this->cache->get($uploadKey)) {
            return $this->response->send(null, HttpResponse::HTTP_GONE);
        }

        $status = $this->verifyPatchRequest($meta);

        if (HttpResponse::HTTP_OK !== $status) {
            return $this->response->send(null, $status);
        }

        $file     = $this->buildFile($meta);
        $checksum = $meta['checksum'];

        try {
            $fileSize = $file->getFileSize();
            $offset   = $file->setKey($uploadKey)->setChecksum($checksum)->upload($fileSize);

            // If upload is done, verify checksum.
            if ($offset === $fileSize) {
                if ( ! $this->verifyChecksum($checksum, $meta['file_path'])) {
                    return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
                }

                $this->event()->dispatch(
                    UploadComplete::NAME,
                    new UploadComplete($file, $this->getRequest(), $this->getResponse())
                );
            } else {
                $this->event()->dispatch(
                    UploadProgress::NAME,
                    new UploadProgress($file, $this->getRequest(), $this->getResponse())
                );
            }
        } catch (FileException $e) {
            return $this->response->send($e->getMessage(), HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
        } catch (OutOfRangeException $e) {
            return $this->response->send(null, HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);
        } catch (ConnectionException $e) {
            return $this->response->send(null, HttpResponse::HTTP_CONTINUE);
        }

        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
            'Content-Type' => self::HEADER_CONTENT_TYPE,
            'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
            'Upload-Offset' => $offset,
        ]);
    }
591619
public function handle()
    {
        $input = $this->getCommandInput();

        $resources = Resource::fromFile($input->resourceFile, $input->langFile);

        $destenationFile = $this->getDestenationFile($input->controllerName, $input->controllerDirectory);

        if ($this->hasErrors($resources, $destenationFile)) {
            return false;
        }

        $requestName = 'Request';
        $requestNameSpace = 'Illuminate\Http\Request';

        if ($input->withFormRequest) {
            $requestName = $input->formRequestName;
            $requestNameSpace = $this->getRequestsNamespace($requestName, $input->formRequestDirectory);

            if (!$this->option('without-form-request')) {
                $this->makeFormRequest($input);
            }
        }

        $fields = $resources->fields;
        $viewVariablesForIndex = $this->getCompactVariablesFor($fields, $this->getPluralVariable($input->modelName), 'index');
        $viewVariablesForShow = $this->getCompactVariablesFor($fields, $this->getSingularVariable($input->modelName), 'show');
        $viewVariablesForEdit = $this->getCompactVariablesFor($fields, $this->getSingularVariable($input->modelName), 'form');
        $modelNamespace = $this->getModelNamespace($input->modelName, $input->modelDirectory);
        $affirmMethod = $this->getAffirmMethod($input->withFormRequest, $fields, $requestNameSpace, $input);
        $classToExtendFullname = $this->getFullClassToExtend($input->extends);
        $namespacesToUse = $this->getRequiredUseClasses($fields, [$modelNamespace, $requestNameSpace, $classToExtendFullname]);
        $dataMethod = $this->getDataMethod($fields, $requestNameSpace . '\\' . $requestName, $input);
        $stub = $this->getStubContent('controller');
        $languages = array_keys(Helpers::getLanguageItems($fields));
        $viewLabels = new ViewLabelsGenerator($input->modelName, $fields, $this->isCollectiveTemplate());
        $standardLabels = $viewLabels->getLabels();

        return $this->replaceViewNames($stub, $input->viewDirectory, $input->prefix)
            ->replaceGetDataMethod($stub, $dataMethod)
            ->replaceCallDataMethod($stub, $this->getCallDataMethod($input->withFormRequest))
            ->replaceModelName($stub, $input->modelName)
            ->replaceNamespace($stub, $this->getControllersNamespace($input->controllerDirectory))
            ->replaceControllerExtends($stub, $this->getControllerExtends($classToExtendFullname))
            ->replaceUseCommandPlaceholder($stub, $namespacesToUse)
            ->replaceRouteNames($stub, $this->getModelName($input->modelName), $input->prefix)
            ->replaceConstructor($stub, $this->getConstructor($input->withAuth))
            ->replaceCallAffirm($stub, $this->getCallAffirm($input->withFormRequest))
            ->replaceAffirmMethod($stub, $affirmMethod)
            ->replacePaginationNumber($stub, $input->perPage)
            ->replaceFileMethod($stub, $this->getUploadFileMethod($fields, $input->withFormRequest))
            ->replaceViewVariablesForIndex($stub, $viewVariablesForIndex)
            ->replaceViewVariablesForShow($stub, $viewVariablesForShow)
            ->replaceViewVariablesForCreate($stub, $this->getCompactVariablesFor($fields, null, 'form'))
            ->replaceViewVariablesForEdit($stub, $viewVariablesForEdit)
            ->replaceWithRelationsForIndex($stub, $this->getWithRelationFor($fields, 'index'))
            ->replaceWithRelationsForShow($stub, $this->getWithRelationFor($fields, 'show'))
            ->replaceRelationCollections($stub, $this->getRequiredRelationCollections($fields))
            ->replaceOnStoreAction($stub, $this->getOnStoreAction($fields))
            ->replaceOnUpdateAction($stub, $this->getOnUpdateAction($fields))
            ->replaceAppName($stub, Helpers::getAppName())
            ->replaceControllerName($stub, $input->controllerName)
            ->replaceDataVariable($stub, 'data')
            ->replaceRequestName($stub, $requestName)
            ->replaceRequestFullName($stub, $requestNameSpace)
            ->replaceRequestVariable($stub, $this->requestVariable)
            ->replaceTypeHintedRequestName($stub, $this->getTypeHintedRequestName($requestName))
            ->replaceStandardLabels($stub, $standardLabels)
            ->createFile($destenationFile, $stub)
            ->info('A controller was crafted successfully.');
    }
185525
public function handle()
    {
        if (in_array(false, array_values($this->initialized))) {
            throw new CorsInitException('Not set "request" or "response"');
        }

        $this->response->setAccessControlAllowCredentials($this->getCredentials());
        $this->response->setAccessControlAllowOrigin($this->getOrigin());
        $this->response->setAccessControlAllowMethods($this->getMethods());
        $this->response->setAccessControlAllowHeaders($this->getAllowheaders());
        $this->response->setAccessControlExposeHeaders($this->getExposeHeaders());
        $this->response->setAccessControlMaxAge($this->getMaxAge());
        $this->response->setAddedStatus(true);
    }
1192006
public function authenticate()
    {
        if (empty($this->request)) {
            throw new Exception\RuntimeException(
                'Request and Response objects must be set before calling authenticate()'
            );
        }

        if ($this->request->getUri()->getScheme() != 'https') {

            return new Result(
                Result::FAILURE_UNCATEGORIZED,
                array(),
                array('Http authentication must be over https')
            );
        }

        return parent::authenticate();
    }