Build a new reponse object from handle execution result
@param  string                  $content Response content
@param  ExecutionInfos          $infos   Execution details
@param  Request\AbstractRequest $request
@return Response
488542
public static function build(
        $content,
        ExecutionInfos $infos,
        Request\AbstractRequest $request
    ) {
        $response = new Response($request);
        $response->setStatus($infos->status);
        $response->setTransactionTime($infos->transactionTime);
        $response->setExecutionInfos($infos);

        //Populate request headers with all really sent headers
        if (!empty($infos->headers)) {
            self::parseHeaders(
                $infos->headers,
                $request
            );
        }

        //Headers are returned with content, so we extract it
        $content = self::parseHeaders($content, $response);

        $response->setBody($content);

        return $response;
    }
1223726
public function handleContentsAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ez:infocollector:read');

        $contents = $request->request->get('ContentId', []);
        $count = count($contents);

        if (empty($contents)) {
            $this->addFlashMessage('errors', 'contents_not_selected');

            return $this->redirectToRoute('netgen_information_collection.route.admin.overview');
        }

        if ($request->request->has('DeleteCollectionByContentAction')) {
            $query = new Query([
                'contents' => $contents,
            ]);
            $this->service->deleteCollectionByContent($query);

            $this->addFlashMessage('success', 'content_removed', $count);

            return $this->redirectToRoute('netgen_information_collection.route.admin.overview');
        }

        $this->addFlashMessage('error', 'something_went_wrong');

        return $this->redirectToRoute('netgen_information_collection.route.admin.overview');
    }
955871
public function create($infos)
    {
        $tabela = $infos['table'];
        $campos = $infos['fields'];
        $camposV = $infos['values'];
        try {
            $camposNome = [];

            for ($i = 0; $i < count($campos); $i++) {
                if ($camposV[$i] != null) {
                    $camposNome[$i] = $campos[$i];
                }
            }

            $camposNome = array_values($camposNome);
            $this->sql = "INSERT INTO $tabela (" . implode(", ", $camposNome) . ") VALUES (";

            for ($j = 0; $j < count($camposNome); $j++) {
                if ($j != count($camposNome) - 1) {
                    $this->sql .= ":" . $camposNome[$j] . ", ";
                } else if ($j == count($camposNome) - 1) {
                    $this->sql .= ":" . $camposNome[$j] . ")";
                }
            }
            return $this->sql;

        } catch (PhiberException $e) {
            throw new PhiberException(new Internationalization("query_processor_error"));
        }
    }
951454
public function callback(ServerRequestInterface $request)
    {
        $response = new Response(200, [
            'Content-Type' => 'text/plain; charset=utf-8',
        ], '');

        return new Promise(function ($resolve, $reject) use (&$request, &$response) {
            try {
                $context = new Context($request, $response);
                $context->setLogger($this->getLogger());

                /**
                 * @var HttpBodyStream $body
                 */
                $body = $request->getBody();
                $body->on('data', function ($data) use (&$request, &$context) {
                    if (!$data) return;
                    $method = $request->getMethod();
                    $contentType = $request->getHeader('Content-Type');
                    if (isset($contentType[0])
                        && (strcasecmp($method, 'POST') === 0 || strcasecmp($method, 'PUT') === 0)
                    ) {
                        if (strpos(strtolower($contentType[0]), 'application/x-www-form-urlencoded') !== false) {
                            parse_str($data, $parsedBody);
                            $request = $request->withParsedBody($parsedBody);
                            $context->setRequest($request);
                        } else if (strpos(strtolower($contentType[0]), 'application/json') !== false) {
                            $parsedBody = json_decode($data, JSON_OBJECT_AS_ARRAY);
                            $request = $request->withParsedBody($parsedBody);
                            $context->setRequest($request);
                        }
                    }
                    $context->setAttribut('httpRawData', $data);
                });
                $body->on('end', function () use (&$context, $resolve) {
                    co(...$this->middlewares)($context);
                    $resolve($context->getReturn());
                });
                $body->on('error', function ($reason) use ($reject) {
                    $reject($reason);
                });
            } catch (\Throwable $exception) {
                // 触发错误异常处理中间件
                $this->onException($exception, $context);
                $rsp = $context->getResponse();
                if ($rsp === $response) {
                    $rsp = $response->withStatus(500);
                    $response->getBody()->write('Internal Server Error');
                }
                $resolve($rsp);
            }
        });
    }
82407
private function createJavascriptResponse($content)
    {
        $rf = $this->app->make(ResponseFactoryInterface::class);

        return $rf->create(
            $content,
            200,
            [
                'Content-Type' => 'application/javascript; charset=' . APP_CHARSET,
                'Content-Length' => strlen($content),
            ]
        );
    }
619872
public function toResponse($request): JsonResponse
    {
        return response()->json([
            'success' => $this->result,
            'message' => ($this->result)
                ? trans('comments::messages.send_success')
                : trans('comments::messages.send_fail'),
        ]);
    }
1324326
private function createThrowableJsonApiResponse(
        Throwable $throwable,
        string $content,
        int $status
    ): ThrowableResponseInterface {
        return new class ($throwable, $content, $status) extends JsonApiResponse implements ThrowableResponseInterface
        {
            /**
             * @var Throwable
             */
            private $throwable;

            /**
             * @param Throwable $throwable
             * @param string    $content
             * @param int       $status
             */
            public function __construct(Throwable $throwable, string $content, int $status)
            {
                parent::__construct($content, $status);
                $this->throwable = $throwable;
            }

            /**
             * @return Throwable
             */
            public function getThrowable(): Throwable
            {
                return $this->throwable;
            }
        };
    }
899232
public function handle($request, Closure $next, $roles, $permissions, $validateAll = false)
    {

        $token = JWTAuth::getToken();

        if (!$token) {
            return Response::apiResponse([
                'httpCode' => 400,
                'message' => 'Token não encontrado ou inválido.'
            ]);
        }

        try {
            $user = $this->auth->authenticate($token);
        } catch (TokenExpiredException $e) {
            return Response::apiResponse([
                'httpCode' => 400,
                'message' => 'O token de acesso expirou.'
            ]);
        } catch (JWTException $e) {
            return Response::apiResponse([
                'httpCode' => 400,
                'message' => 'Token inválido.'
            ]);
        }

        if (!$user) {
            return Response::apiResponse([
                'httpCode' => 404,
                'message' => 'Usuário não encontrado.'
            ]);
        }

        if (!$request->user()->ability(explode('|', $roles), explode('|', $permissions),
            ['validate_all' => $validateAll])
        ) {
            return Response::apiResponse([
                'httpCode' => 401,
                'message' => 'Acesso não autorizado.'
            ]);
        }

        $this->events->fire('tymon.jwt.valid', $user);

        return $next($request);
    }
603963
protected function createEntityFromContent(string $content): EntityInterface
    {
        $result = $this->createEntity();
        $result->readData(new DataContainer($this->decodeContent($content)));
        return $result;
    }
1041808
public function make($content = '', $status = 200, array $headers = [])
    {
        respondWith(response()->make($content, $status, $headers));
    }
770277
protected function parseResponse($rawResponse, $infoList, $command)
    {
        $httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
        $messageList = [
            "HTTP Response Status Code: {$httpStatusCode}",
            WebDriver_Exception_Protocol::getCommandDescription($command)
        ];
        switch ($httpStatusCode) {
            case 0:
                $message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
                throw new WebDriver_NoSeleniumException($message);
            case WebDriver_Http::SUCCESS_OK:
                $decodedJsonList = json_decode($rawResponse, true);
                if ($decodedJsonList === null) {
                    $errorList = ["Can't decode response JSON:", json_last_error_msg()];
                    $message = $this->buildResponseErrorMessage($errorList, $messageList);
                    throw new WebDriver_Exception_Protocol($message);
                }
                if (isset($decodedJsonList['status']) &&
                    !WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
                    throw WebDriver_Exception_FailedCommand::factory(
                        $command,
                        $infoList,
                        $rawResponse,
                        $decodedJsonList
                    );
                }
                return $decodedJsonList;
            default:
                if (WebDriver_Http::isError($httpStatusCode)) {
                    throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
                }
                $errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
                $message = $this->buildResponseErrorMessage($errorMessage, $messageList);
                throw new WebDriver_Exception($message);
        }
    }
825679
public function updateAction(Request $request, ContentNode $contentNode, $isSimpleForm = false)
    {
        $em = $this->getDoctrine()->getManager();
        $repository = $this->getDoctrine()->getRepository('MMCmfNodeBundle:Node');

        $rootNode = null;

        if ((int)$request->get('root_node')) {
            $rootNode = $repository->find((int)$request->get('root_node'));
        }

        //check if node need "simple" validation
        if ($isSimpleForm)
            $editForm = $this->createSimpleEditForm($contentNode, $rootNode);
        else
            $editForm = $this->createEditForm($contentNode, $rootNode);

        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            $markup = $this->get('mm_cmf_content.mm_cmf_parse_twig_extension')->cmfParse(
                $this->get('twig'),
                $contentNode
            );
            return new JsonResponse(array(
                    'success' => true,
                    'data' => array(
                        'id' => $contentNode->getId(),
                        'markup' => $markup
                    ))
            );
        }

        return new JsonResponse(array('success' => false));
    }
87037
public function handle(fw\Module\AbstractModule $module, $request) {
		
		$fq_modclass_name = get_class($module);
		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\';
		
		$args = explode( '@', $request, 2);
		switch(count($args)) {
			case 1:
				$ctrl_name = $args[0];
				$method = 'index';
				break;
			case 2:
				list($ctrl_name, $method) = $args;
				break;
			default:
				break;
		}
		
		$ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller';
		if(class_exists($ctrl_class) 
		    && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
			&& $ctrl = new $ctrl_class($module) ) {
			if(method_exists($ctrl, $method)) {
			    try {
			        call_user_func_array(array($ctrl, $method), array());
			    }
			    catch (MvcException $ex) {
			        if(!headers_sent()) {
			            http_response_code($ex->getHttpCode());
			        }
			        echo $ex->getMessage();			        
			    }
			}
			 else {
				 throw new \Exception('The page requested does not exist');
			 }
		 }
		 else {
			 throw new \Exception('The page requested does not exist');
		 }
    }
232002
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1)
    {
        $key = $this->resolveRequestSignature($request);

        if ($this->limiter->tooManyAttempts($key, $maxAttempts, $decayMinutes)) {
            return $this->buildResponse($key, $maxAttempts);
        }

        $this->limiter->hit($key, $decayMinutes);

        $response = $next($request);

        return $this->addHeaders(
            $response, $maxAttempts,
            $this->calculateRemainingAttempts($key, $maxAttempts)
        );
    }
668864
public function infoAction(Request $request, SalesChannelContext $context): Response
    {
        $page = $this->infoLoader->load($request, $context);

        return $this->renderStorefront('@Storefront/layout/header/actions/cart-widget.html.twig', ['page' => $page]);
    }
1168762
public function post($uri, AbstractRequest $request = null)
    {
        $http = $this->getHttpClone();

        $http->setOption(CURLOPT_POST, true);
        $http->setOption(CURLOPT_URL, $uri);
        if ($request) {
            $http->setOption(CURLOPT_POSTFIELDS, $this->buildPostData($request->getQuery()));
        }

        return $http->execute();
    }
843899
public function execute($content, $params = array(), $sandbox=false, $srcinfo=null) {

        $obj = $this;

        ob_start();

        lexy_eval_with_params($obj, $content, $params, $sandbox, $srcinfo);

        $output = ob_get_clean();

        return $output;
    }