Makes a request.

@param \Symfony\Component\BrowserKit\Request $request

@return \Symfony\Component\BrowserKit\Response
@throws \RuntimeException
557334
public function doRequest($request)
    {
        $application = $this->getApplication();
        if (!$application instanceof Application && !$application instanceof MicroApplication) {
            throw new RuntimeException('Unsupported application class.');
        }

        $di = $application->getDI();
        /** @var Http\Request $phRequest */
        if ($di->has('request')) {
            $phRequest = $di->get('request');
        }

        if (!$phRequest instanceof Http\RequestInterface) {
            $phRequest = new Http\Request();
        }

        $uri         = $request->getUri() ?: $phRequest->getURI();
        $pathString  = parse_url($uri, PHP_URL_PATH);
        $queryString = parse_url($uri, PHP_URL_QUERY);

        $_SERVER = $request->getServer();
        $_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod());
        $_SERVER['REQUEST_URI'] = null === $queryString ? $pathString : $pathString . '?' . $queryString;

        $_COOKIE  = $request->getCookies();
        $_FILES   = $this->remapFiles($request->getFiles());
        $_REQUEST = $this->remapRequestParameters($request->getParameters());
        $_POST    = [];
        $_GET     = [];

        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
            $_GET = $_REQUEST;
        } else {
            $_POST = $_REQUEST;
        }

        parse_str($queryString, $output);
        foreach ($output as $k => $v) {
            $_GET[$k] = $v;
        }

        $_GET['_url']            = $pathString;
        $_SERVER['QUERY_STRING'] = http_build_query($_GET);

        Di::reset();
        Di::setDefault($di);

        $di['request'] = Stub::construct($phRequest, [], ['getRawBody' => $request->getContent()]);

        $response = $application->handle();
        if (!$response instanceof Http\ResponseInterface) {
            $response = $application->response;
        }

        $headers = $response->getHeaders();
        $status = (int) $headers->get('Status');

        $headersProperty = new ReflectionProperty($headers, '_headers');
        $headersProperty->setAccessible(true);
        $headers = $headersProperty->getValue($headers);
        if (!is_array($headers)) {
            $headers = [];
        }

        $cookiesProperty = new ReflectionProperty($di['cookies'], '_cookies');
        $cookiesProperty->setAccessible(true);
        $cookies = $cookiesProperty->getValue($di['cookies']);
        if (is_array($cookies)) {
            $restoredProperty = new ReflectionProperty('\Phalcon\Http\Cookie', '_restored');
            $restoredProperty->setAccessible(true);
            $valueProperty = new ReflectionProperty('\Phalcon\Http\Cookie', '_value');
            $valueProperty->setAccessible(true);
            foreach ($cookies as $name => $cookie) {
                if (!$restoredProperty->getValue($cookie)) {
                    $clientCookie = new Cookie(
                        $name,
                        $valueProperty->getValue($cookie),
                        $cookie->getExpiration(),
                        $cookie->getPath(),
                        $cookie->getDomain(),
                        $cookie->getSecure(),
                        $cookie->getHttpOnly()
                    );
                    $headers['Set-Cookie'][] = (string)$clientCookie;
                }
            }
        }

        return new Response(
            $response->getContent() ?: '',
            $status ? $status : 200,
            $headers
        );
    }
837967
public function handle(Message\ServerRequestInterface $request): Message\ResponseInterface
    {
        if ($this->middleware->valid()) {
            $middleware = $this->middleware->current();
            assert($middleware instanceof MiddlewareInterface, new \TypeError('Invalid middleware type'));
            $this->middleware->next();

            return $middleware->process($request, $this);
        }

        if (null === $this->response) {
            throw new \RuntimeException('No base response provided');
        }

        return $this->response;
    }
211661
public function handle(Request $request) : Response
    {
        try {
            return $this->handleRequest($request);
        } catch (HttpException $e) {
            return $this->handleHttpException($e, $request);
        } catch (\Throwable $e) {
            return $this->handleUncaughtException($e, $request);
        }
    }
1359845
public function run(Request $request) {
		$page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
		$page->setTitle($this->getServiceContainer()->getTranslator()->trans('registration'));

		if ($request->isMethod('POST')) {
			$post = $request->request;
			$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();
			$translator = $this->getServiceContainer()->getTranslator();

			// check errors first
			$errors = [];

			// username
			if ($prefs->getUserLogin() == SystemPreferences::LOGIN_USERNAME && !$post->has('user-name')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('user_name')
				]);
			}

			// email
			$emailRequired = $prefs->getUserEmail()
				|| $prefs->getUserLogin() == SystemPreferences::LOGIN_EMAIL
				|| $prefs->getUserLogin() == SystemPreferences::LOGIN_USERNAME_EMAIL;

			if ($emailRequired && !$post->has('email')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('email')
				]);
			}

			// given name
			if ($prefs->getUserNames() == SystemPreferences::VALUE_REQUIRED && !$post->has('given-name')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('given_name')
				]);
			}

			// family name
			if ($prefs->getUserNames() == SystemPreferences::VALUE_REQUIRED && !$post->has('family-name')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('family_name')
				]);
			}

			// birth
			if ($prefs->getUserBirth() == SystemPreferences::VALUE_REQUIRED && !$post->has('birth')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('birth')
				]);
			}

			// sex
			if ($prefs->getUserSex() == SystemPreferences::VALUE_REQUIRED && !$post->has('sex')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('sex')
				]);
			}

			// passwords
			if (!$post->has('password') && !$post->has('password_confirm')) {
				$errors[] = $translator->trans('error.required', [
					'field' => $translator->trans('password')
				]);
			}

			if ($post->get('password') != $post->get('password_confirm')) {
				$errors[] = $translator->trans('error.password_nomatch');
			}


			$vars = ['failures' => $errors, 'fields' => $post->all()];
			if (count($errors) == 0) {
				$serializer = User::getSerializer();
				$fields = $serializer->getFields();
				$attribs = [
					'password' => $post->get('password')
				];

				foreach ($fields as $field) {
					if ($post->has($field)) {
						$attribs[$field] = $post->get($field);
					}
				}

				$domain = new UserDomain($this->getServiceContainer());
				$payload = $domain->create(['attributes' => $attribs]);
				if ($payload instanceof NotValid) {
					$payload = new NotValid(array_merge($payload->get(), $vars));
				} else if ($payload instanceof Created) {
					$user = $payload->getModel();

					// send mail
					$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();
					$localeService = $this->getServiceContainer()->getLocaleService();
					$file = $localeService->findLocaleFile('/keeko/account/locales/{locale}/mail/registration.twig');
					$body = $this->render($file, [
						'user' => $user->getDisplayName(),
						'username' => $user->getUserName(),
						'plattform' => $prefs->getPlattformName(),
					]);

					$mailer = $this->getServiceContainer()->getMailer();
					$message = $this->getServiceContainer()->createMessage();
					$message->setTo($user->getEmail());
					$message->setSubject($translator->trans('registration.subject', [
						'plattform' => $prefs->getPlattformName()
					]));
					$message->setBody($body);
					$mailer->send($message);
				}
			} else {
				$post->remove('password');
				$post->remove('password_confirm');
				$payload = new NotValid($vars);
			}
		} else {
			$payload = new Blank();
		}

		return $this->responder->run($request, $payload);
	}
974870
public function run(Request $request)
    {
        $this->container = $this->container ?: new Container;
        
        try {
            if (! is_string($this->action['uses'])) {
                return $this->runCallable($request);
            }
            
            list($class, $method) = explode('@', $this->action['uses']);
            $cl = new ClassLoader;
            $cl->addPsr4($this->getAppNamespace(), app('path'));
            $file = $cl->findFile($class);
            $cmd = 'php -l ' . $file;
            
            if (strpos(exec($cmd, $output), 'No syntax errors detected') === false) {
                $route = array_get($this->action, 'as', $this->action['uses']);
                $error = head(array_filter($output));
                
                throw new SyntaxErrorException($route, $error);
            }
            
            set_error_handler([$this, 'error']);
            
            if ($this->customDispatcherIsBound()) {
                return $this->runWithCustomDispatcher($request);
            }
            
            return $this->runController($request);
        } catch (HttpResponseException $e) {
            return $e->getResponse();
        }
    }
1020010
public function indexAction(Request $request)
    {
        $configuration = $this->getConfiguration($request);

        if (!$configuration->getGridType()) {
            throw new \RuntimeException('You must set the gridType on the CRUD configuration');
        }

        $sortField = $request->get('sort_by', $configuration->getDefaultSortField());
        $sortOrder = $request->get('sort_order', $configuration->getDefaultSortOrder());

        // Ensure that the correct field is active
        $request->query->set('sort_by', $sortField);
        $request->query->set('sort_order', $sortOrder);

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->getRepository()->createQueryBuilder('o');

        // If no specific entity alias is given, link the sort field to the main entity
        if (!strpos($sortField, '.') && !(strpos($sortField, '_') === 0)) {
            $sortField = sprintf('o.%s', $sortField);
        }
        $queryBuilder->addOrderBy($sortField, $sortOrder);

        $this->configureListCriteria($request, $queryBuilder);

        $pager = new Pagerfanta(new DoctrineORMAdapter($queryBuilder));
        $pager->setMaxPerPage($request->get('resultsPerPage', $configuration->getResultsPerPage()));
        $pager->setCurrentPage($request->get('page', 1));

        /** @var Grid $grid */
        $grid = $this->get('grid_factory')->createGrid(
            $configuration->getGridType(),
            $configuration->getGridOptions()
        );

        return $this->render($this->getTemplate($request, 'index'), array_merge([
            'base_template' => $this->getTemplate($request, 'base'),
            'config' => $configuration,
            'grid'   => $grid->createView(),
            'pager'  => $pager,
        ], $configuration->getTemplateVariables()));
    }
200605
public function run(Request $request) {
		$info = Embed::create($request->query->get('url'));

		return $this->responder->run($request, new Found(['info' => $info]));
	}
986719
public function run(Request $request) {
		$page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
		$page->setTitle($this->getServiceContainer()->getTranslator()->trans('sessions'));

		if ($request->isMethod('POST')) {
			$post = $request->request;
			if ($post->has('token')) {
				SessionQuery::create()->findOneByToken($post->get('token'))->delete();
				$service = $this->getServiceContainer();
				$accountUrl = $service->getPreferenceLoader()->getSystemPreferences()->getAccountUrl();
				$translator = $service->getTranslator();
				$url = sprintf('%s%s/%s',
					$accountUrl,
					$translator->trans('slug.settings'),
					$translator->trans('slug.settings.sessions')
				);
				return new RedirectResponse($url);
			}
		}

		return $this->responder->run($request);
	}
185308
public function post(Request $request)
    {
        $this->authorizeUserAction('create');

        $model = new static::$model;

        $this->restfulService->validateResource($model, $request->input());

        $resource = $this->restfulService->persistResource(new $model($request->input()));

        // Retrieve full model
        $resource = $model::with($model::$localWith)->where($model->getKeyName(), '=', $resource->getKey())->first();

        if ($this->shouldTransform()) {
            $response = $this->response->item($resource, $this->getTransformer())->setStatusCode(201);
        } else {
            $response = $resource;
        }

        return $response;
    }
887516
public function dispatch(SymfonyRequest $request)
    {
        $path = rawurldecode($request->getPathInfo());

        if (substr($path, 0, 3) == '../' || substr($path, -3) == '/..' || strpos($path, '/../') ||
            substr($path, 0, 3) == '..\\' || substr($path, -3) == '\\..' || strpos($path, '\\..\\')) {
            throw new \RuntimeException(t('Invalid path traversal. Please make this request with a valid HTTP client.'));
        }

        $response = null;
        if ($this->app->isInstalled()) {
            $response = $this->getEarlyDispatchResponse();
        }
        if ($response === null) {
            $response = $this->handleDispatch($request);
        }

        return $response;
    }
121834
final public function run(Request $request)
    {
        $this->request = $request;
        $path = $this->request->getUri()->getPath();
        $this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/";
        $this->requestedMethod = strtoupper($this->request->getMethod());
        $this->requestedRepresentation = $this->request->getAccept();
        $this->verifyRequestMethod();
        $route = $this->findRouteFromRequest();
        $this->prepareResponse($route);
    }
809071
public function execute($request)
    {
        ob_start();
        $logger          = $GLOBALS['logger'];
        $this->_request  = $request;
        $this->_response = new HttpResponse();
        try {
            WebSessionManager::updateActiveSession();
            foreach ($this->_preProcessors as $preProcessor) {
                $preProcessor->process($this->_request);
            }

            $functionToCall = $this->command->getFunction();
            if (empty($functionToCall) === true) {
                $functionToCall = 'default';
            }

            if (!is_callable(array(&$this,'_'.$functionToCall))) {
                $functionToCall = 'error';
            }

            call_user_func(array(&$this,'_'.$functionToCall), $this->_request);
            foreach ($this->_postProcessors as $postProcessor) {
                $postProcessor->process($this->_response);
            }

            ob_end_clean();
            if (empty($this->_response)) {
                $this->_response = new HttpResponse(); 
            }

            if($this->_response->getEncoding() == null) {
                $responseMode = $this->_request->getParam('mode');
                if ($responseMode === 'ui') {
                    $this->_response->setEncoding('html');
                } else if ($responseMode === 'data') {
                    $this->_response->setEncoding('json');
                }
            }
            $this->_response->send();
        } catch (ServiceException $se) {
            $this->_response = new HttpResponse();
            $response->addHeader('HTTP/1.1 400 Bad Request');
            $this->_response->send();
        } catch(BadResponseException $bre) {
            $renderer = new TwigRenderer('500.html');
            if($renderer->exists()) {
                $this->_response = new HttpResponse('none', $renderer);
            } else 
                $this->_response = new HttpResponse();
            $response->addHeader('HTTP/1.1 500 Internal Server Error');
            $this->_response->send();
        }//end try

    }
664868
public function route(Request $request) {
        $httpMethod = $request->getMethod();

        if ($httpMethod === 'BREW') {
            throw new RuntimeException('I\'m a teapot!', 418);
        }

        if (!isset(self::$supportedHttpMethods[$httpMethod])) {
            throw new RuntimeException('Unsupported HTTP method: ' . $httpMethod, 501);
        }

        $path = $request->getPathInfo();
        $matches = [];

        foreach ($this->routes as $resourceName => $route) {
            if (preg_match($route, $path, $matches)) {
                break;
            }
        }

        // Path matched no route
        if (!$matches) {
            throw new RuntimeException('Not Found', 404);
        }

        // Create and populate a route instance that we want to inject into the request
        $route = new Route();
        $route->setName($resourceName);

        // Inject all matches into the route as parameters
        foreach ($matches as $key => $value) {
            if (is_string($key)) {
                $route->set($key, $value);
            }
        }

        // Store the route in the request
        $request->setRoute($route);
    }
1071311
public function request(Request $request)
    {
        if (!extension_loaded('curl')) {
            throw new \RuntimeException('The cURL extension must be loaded.');
        }

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt_array($curl, $this->curlOptions);
        curl_setopt($curl, CURLOPT_URL, $request->getUri());
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);

        // add headers
        $headers = array();
        foreach ($request->headers->all() as $name => $value) {
            if (is_array($value)) {
                foreach ($value as $subValue) {
                    $headers[] = sprintf('%s: %s', $name, $subValue);
                }
            } else {
                $headers[] = sprintf('%s: %s', $name, $value);
            }
        }
        if (count($headers) > 0) {
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        }

        // set method
        $method = strtoupper($request->getMethod());
        if ('POST' === $method) {
            curl_setopt($curl, CURLOPT_POST, true);

            if (!$request->headers->has('Content-Type') || 'multipart/form-data' !== $request->headers->get('Content-Type')) {
                $postFields = $this->urlEncodeArray($request->request->all());
            } else {
                $postFields = $request->request->all();
            }

            curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
        } elseif ('PUT' === $method) {
            curl_setopt($curl, CURLOPT_PUT, true);
        } elseif ('HEAD' === $method) {
            curl_setopt($curl, CURLOPT_NOBODY, true);
        }

        // perform the request
        if (false === $returnTransfer = curl_exec($curl)) {
            throw new CommunicationException(
                'cURL Error: '.curl_error($curl), curl_errno($curl)
            );
        }

        $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $headers = array();
        if (preg_match_all('#^([^:\r\n]+):\s+([^\n\r]+)#m', substr($returnTransfer, 0, $headerSize), $matches)) {
            foreach ($matches[1] as $key => $name) {
                $headers[$name] = $matches[2][$key];
            }
        }

        $response = new RawResponse(
            substr($returnTransfer, $headerSize),
            curl_getinfo($curl, CURLINFO_HTTP_CODE),
            $headers
        );
        curl_close($curl);

        return $response;
    }
1320463
public function handle(Request $request)
	{
		$response = $this->next($request);

		try
		{
			$this->app->get('arguments')->parse();
		}
		catch (UnsupportedCommandException $e)
		{
			$this->app->get('output')->error($e->getMessage());
		}
		catch (UnsupportedTaskException $e)
		{
			$this->app->get('output')->error($e->getMessage());
		}

		return $response;
	}
972707
public function doRequestInProcess($request)
    {
        if ($this->mockedResponse) {
            $response = $this->mockedResponse;
            $this->mockedResponse = null;
            return $response;
        }

        $requestCookie = $request->getCookies();
        $requestServer = $request->getServer();
        $requestFiles = $this->remapFiles($request->getFiles());

        $parseResult = parse_url($request->getUri());
        $uri = $parseResult["path"];
        if (array_key_exists("query", $parseResult)) {
            $uri .= "?" . $parseResult["query"];
        }

        $requestRequestArray = $this->remapRequestParameters($request->getParameters());

        $requestServer['REQUEST_METHOD'] = strtoupper($request->getMethod());
        $requestServer['REQUEST_URI'] = $uri;
        $requestServer['HTTP_HOST'] = $this->domain;
        $requestServer['SERVER_PROTOCOL'] = 'HTTP/1.1';
        $requestServer['SERVER_NAME'] = $this->domain;
        $requestServer['HTTP_CLIENT_IP'] = '127.0.0.1';

        $this->index = $this->uriToIndexMapper->getIndexForUri($uri);

        $phpSelf = str_replace($this->rootFolder, '', $this->index);
        $requestServer['PHP_SELF'] = $phpSelf;

        $env = [
            'headers' => $this->headers,
            'cookie' => $requestCookie,
            'server' => $requestServer,
            'files' => $requestFiles,
            'request' => $requestRequestArray,
        ];

        if (strtoupper($request->getMethod()) == 'GET') {
            $env['get'] = $env['request'];
        } else {
            $env['post'] = $env['request'];
        }

        $requestScript = dirname(dirname(__DIR__)) . '/scripts/request.php';

        $command = PHP_BINARY .
            ' ' . escapeshellarg($requestScript) .
            ' ' . escapeshellarg($this->index) .
            ' ' . escapeshellarg(base64_encode(serialize($env)));

        $process = new Process($command);
        $process->run();
        $rawProcessOutput = $process->getOutput();

        $unserializedResponse = @unserialize(base64_decode($rawProcessOutput));

        if (false === $unserializedResponse) {
            $message = 'Server responded with: ' . $rawProcessOutput;
            throw new ModuleException(\Codeception\Module\WordPress::class, $message);
        }

        $_SERVER = empty($unserializedResponse['server']) ? [] : $unserializedResponse['server'];
        $_FILES = empty($unserializedResponse['files']) ? [] : $unserializedResponse['files'];
        $_REQUEST = empty($unserializedResponse['request']) ? [] : $unserializedResponse['request'];
        $_GET = empty($unserializedResponse['get']) ? [] : $unserializedResponse['get'];
        $_POST = empty($unserializedResponse['post']) ? [] : $unserializedResponse['post'];

        $content = $unserializedResponse['content'];
        $headers = $this->replaceSiteUrlDeep($unserializedResponse['headers'], $this->url);

        $response = new Response($content, $unserializedResponse['status'], $headers);

        return $response;
    }
837157
public function createAction(Request $request)
    {
        $this->registerBreadcrubms()->addItem($this->get("translator")->trans("Add"));

        $entity = $this->getNewEntity();
        $form = $this->createCreateForm($entity);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            try {
                if ($form->get("saveAndPublish")->isClicked()) {
                    $entity->setPublished(1);
                }
            } catch (OutOfBoundsException $e) {

            }

            $em->persist($entity);

            $em->flush();

            $this->get('session')->getFlashBag()->add('notice', $this->getEntityName() . ' has been created!');

            if ($form->get("saveAndExit")->isClicked()) {
                return $this->redirect($this->generateUrl($this->getRouteName(), $this->getRouteParams()));
            } else {
                try {
                    if ($form->get("addNext")->isClicked()) {
                        return $this->redirect($this->generateUrl($this->getRouteName() . "Add", $this->getRouteParams()));
                    }
                } catch (OutOfBoundsException $e) {

                }
                return $this->redirect($this->generateUrl($this->getRouteName() . "Edit", $this->getRouteParams(['id' => $entity->getId()])));
            }
        }

        return $this->render($this->getListTemplate() . ":edit.html.twig", [
            'entity' => $entity,
            'form' => $form->createView()
        ]);
    }