@param Request $request

@return Response
968561
public function addAction(Request $request): Response
    {
        $form = $this->formFactory->addTranslation();
        $form->handleRequest($request);

        /** @var TranslationAddData $data */
        $data = $form->getData();
        $location = $data->getLocation();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (TranslationAddData $data) {
                $location = $data->getLocation();
                $contentInfo = $location->getContentInfo();
                $language = $data->getLanguage();
                $baseLanguage = $data->getBaseLanguage();

                return new RedirectResponse($this->generateUrl('ezplatform.content.translate', [
                    'contentId' => $contentInfo->id,
                    'fromLanguageCode' => null !== $baseLanguage ? $baseLanguage->languageCode : null,
                    'toLanguageCode' => $language->languageCode,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        $redirectionUrl = null !== $location
            ? $this->generateUrl('_ezpublishLocation', ['locationId' => $location->id])
            : $this->generateUrl('ezplatform.dashboard');

        return $this->redirect($redirectionUrl);
    }
797618
public function receiveRequest(Request $request): Response
    {
        $curie = $request::schema()->getCurie();
        $curieStr = $curie->toString();

        if (isset($this->handlers[$curieStr])) {
            $handler = $this->handlers[$curieStr];
        } else {
            try {
                $handler = $this->locator->getRequestHandler($curie);
            } catch (\Throwable $e) {
                return $this->createResponseForFailedRequest($request, $e);
            }

            $this->handlers[$curieStr] = $handler;
        }

        try {
            $request->freeze();
            $response = $handler->handleRequest($request, $this->locator->getPbjx());
            $response->set('ctx_request_ref', $request->generateMessageRef());
            if ($request->has('ctx_correlator_ref')) {
                $response->set('ctx_correlator_ref', $request->get('ctx_correlator_ref'));
            }

            return $response;
        } catch (\Throwable $e) {
            return $this->createResponseForFailedRequest($request, $e);
        }
    }
1239118
public function handleAction(Request $request): Response
    {
        $extras = $request->request->get('extras', []);

        if (!$this->hashHandler->verify($extras['worker'] ?? [], false)) {
            return JsonResponse::create(['invalid' => true, 'message' => 'Invalid hash verify.'], 500);
        }

        try {
            $result = $this->bus->dispatch($this->decoder->decode([
                'body' => $request->getContent(),
                'headers' => ['type' => $request->headers->get('x-chang-msg-type')],
            ])->with(new ReceivedStamp()));
        } catch (\Exception $e) {
            return JsonResponse::create(['message' => $e->getMessage()], 500);
        }

        $this->hashHandler->flush();

        if ($result instanceof AbstractMessage && $result->isExpired()) {
            return JsonResponse::create(['expired' => true, 'message' => 'Message was expired.'], 500);
        }

        return JsonResponse::create([], 200);
    }
1003931
public function send(Request $request)
    {
        foreach ($this->cookies as $cookie) {
            $request->addCookie($cookie);
        }

        $response = $this->client->request($request);

        if ($response->getCookies()) {
            $this->cookies = $response->getCookies();
        }

        return $response;
    }
667783
public function send(Request $request)
    {
        $request->configure($this->config);

        $httpClient = new \GuzzleHttp\Client();

        $r = $httpClient->request('POST', $this->getUrl(), [
            'body' => \GuzzleHttp\Psr7\stream_for((string) $request),
        ]);

        return Response::create($r->getBody()->getContents());
    }
744540
protected function sendRequest(Request $request)
    {
        $curl = curl_init($this->getUrl($request));

        curl_setopt_array($curl, $this->curlOptions);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($request->getRequestFields()));

        $response = curl_exec($curl);

        if(curl_errno($curl))
        {
            $error_message  = 'Error occurred: ' . curl_error($curl);
            $error_code     = curl_errno($curl);
        }
        elseif(curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200)
        {
            $error_code     = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            $error_message  = "Error occurred. HTTP code: '{$error_code}'";
        }

        curl_close($curl);

        if (!empty($error_message))
        {
            throw new RequestException($error_message, $error_code);
        }
        else
        {
            return $response;
        }
    }
646466
public function request(Request $request) : Response
    {
        if (!$this->resource) {
            $this->resource = curl_init();
        }

        // options
        $options = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => true,
        ];

        // gzip, deflate
        if ($this->options[self::OPTIONS_ACCEPT_ENCODING]) {
            if ($this->options[self::OPTIONS_ACCEPT_ENCODING] == true) {
                $options[CURLOPT_ENCODING] = ''; //force curl to send all Accept-Encoding available
            } else {
                $options[CURLOPT_ENCODING] = $this->options[self::OPTIONS_ACCEPT_ENCODING];
            }
        }

        // ssl
        if (isset($this->options[self::OPTIONS_SSL_VERIFY]) && $this->options[self::OPTIONS_SSL_VERIFY] === false) {
            $options[CURLOPT_SSL_VERIFYHOST] = false;
            $options[CURLOPT_SSL_VERIFYPEER] = false;
        }

        // timeout
        if ($this->options[self::OPTIONS_TIMEOUT]) {
            $options[CURLOPT_TIMEOUT_MS] = $this->options[self::OPTIONS_TIMEOUT];
        }

        if ($this->options[self::OPTIONS_CONNECT_TIMEOUT]) {
            $options[CURLOPT_CONNECTTIMEOUT_MS] = $this->options[self::OPTIONS_CONNECT_TIMEOUT];
        }

        // proxy
        if (!empty($this->options[self::OPTIONS_PROXY])) {
            $options[CURLOPT_PROXY] = $this->options[self::OPTIONS_PROXY];
        }

        // proxy
        if (!empty($this->options[self::OPTIONS_FOLLOW_REDIRECTION])) {
            $options[CURLOPT_FOLLOWLOCATION] = $this->options[self::OPTIONS_FOLLOW_REDIRECTION];

            if (!empty($this->options[self::OPTIONS_MAX_REDIRECTION])) {
                $options[CURLOPT_MAXREDIRS] = $this->options[self::OPTIONS_MAX_REDIRECTION];
            }
        }

        // debug temporary files
        if (!empty($this->options[self::OPTIONS_DEBUG])) {
            $options[CURLOPT_VERBOSE] = true;
            $options[CURLOPT_STDERR] = fopen('php://temp', 'rw');
        }

        // headers handling
        $headers = array_merge($this->defaultHeader, $request->getHeaders());

        // add cookie to current headers
        if ($request->getCookies()) {
            $cookies = [];
            foreach ($request->getCookies() as $name => $cookie) {
                $cookies[] = $name . '=' . urlencode($cookie->getValue());
            }

            $headers['Cookie'] = implode('; ', $cookies);
        }

        if ($headers) {
            $finalHeaders = [];
            foreach ($headers as $name => $value) {
                $finalHeaders[] = $name . ': ' . $value;
            }
            $options[CURLOPT_HTTPHEADER] = $finalHeaders;
        }

        // handle post
        $options[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
        if ($request->getMethod() != 'GET') {
            if ($request->getPayload()) {
                $options[CURLOPT_POSTFIELDS] = $request->getPayload();
            } elseif ($request->getHeader('Content-Type') == 'multipart/form-data') {
                // as an array(): The data will be sent as multipart/form-data
                // which is not always accepted by the serve

                // There are "@" issue on multipart POST requests.
                $options[CURLOPT_SAFE_UPLOAD] = true;
                $options[CURLOPT_POSTFIELDS] = $request->getPosts();
            } else {
                // as url encoded string: The data will be sent as application/x-www-form-urlencoded,
                // which is the default encoding for submitted html form data.
                $options[CURLOPT_POSTFIELDS] = http_build_query($request->getPosts());
            }
        }

        // progress
        if ($this->progress) {
            $options[CURLOPT_NOPROGRESS] = false;
            $options[CURLOPT_PROGRESSFUNCTION] = $this->progress;
            $options[CURLOPT_BUFFERSIZE] = 1024;
        }

        // user & password
        if ($request->getUri()->getUser()) {
            $options[CURLOPT_USERPWD] = $request->getUri()->getUser() .
                ($request->getUri()->getPassword() ? ':' . $request->getUri()->getPassword() : '');
        }

        // final options
        $options[CURLOPT_URL] = $request->getUri()->get(false);

        curl_reset($this->resource);
        curl_setopt_array($this->resource, $options);

        // send request
        $requestEvent = new TimerEvent($this->options[self::OPTIONS_EVENTS_PREFIX] . '.request');
        $response = curl_exec($this->resource);
        $infos = curl_getinfo($this->resource);

        // request event
        $requestEvent->addData([
            'method' => $request->getMethod(),
            'url' => $request->getUri()->get(false),
            'code' => $infos['http_code'],
            'header size' => $infos['header_size'],
            'request size' => $infos['request_size'],
        ]);
        self::emit($requestEvent);

        // generate events for all duration
        $data = [
            'method' => $request->getMethod(),
            'url' => $request->getUri()->get(false),
            'code' => $infos['http_code'],
        ];

        $event = new ManualTimerEvent($this->options[self::OPTIONS_EVENTS_PREFIX] . '.nameLookup', $data);
        $event->setDuration($infos['namelookup_time'])
            ->setStart($requestEvent->getStart());
        self::emit($event);

        $event = new ManualTimerEvent($this->options[self::OPTIONS_EVENTS_PREFIX] . '.connect', $data);
        $event->setDuration($infos['connect_time'])
            ->setStart($requestEvent->getStart() + $infos['namelookup_time']);
        self::emit($event);

        // debug log
        if (!empty($this->options[self::OPTIONS_DEBUG])) {
            rewind($options[CURLOPT_STDERR]);
            $log = stream_get_contents($options[CURLOPT_STDERR]);

            if (isset($options[CURLOPT_POSTFIELDS]) && is_array($options[CURLOPT_POSTFIELDS])) {
                $log .= json_encode($log) . "\r\n";
            } elseif (isset($options[CURLOPT_POSTFIELDS])) {
                $log .= $options[CURLOPT_POSTFIELDS] . "\r\n";
            }

            if ($response) {
                $log = $log . "\r\n" . htmlentities(explode("\r\n\r\n", $response)[1]);
            }
            self::logger()->debug($log);
        }

        // connection error
        if ($response === false) {
            $code = curl_errno($this->resource);
            $message = curl_error($this->resource);

            throw new ConnectionException($request, $message, $code);
        }

        // final response
        $response = new Response($response);

        if ($response->getStatus() >= 400) {
            throw new RequestException($request, $response, $response->getStatus());
        }

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

		$arguments = $this->app['arguments'];
		$output    = $this->app['output'];

		// Check for interactivity flag and set on output accordingly
		if ($arguments->getOpt('non-interactive'))
		{
			$output->makeNonInteractive();
		}

		// Check for color flag and set on output accordingly
		if ($arguments->getOpt('no-colors'))
		{
			$output->makeUnColored();
		}

		// If task is help, set the output to our output class with extra methods for rendering help doc
		if ($arguments->get('task') == 'help')
		{
			$output = $output->getHelpOutput();
		}

		// If the format opt is present, try to use the appropriate output subclass
		if ($arguments->getOpt('format'))
		{
			$output = $output->getOutputFormatter($arguments->getOpt('format'));
		}

		// Register any user specific events
		if ($hooks = Config::get('hooks'))
		{
			foreach ($hooks as $trigger => $scripts)
			{
				foreach ($scripts as $script)
				{
					Event::register($trigger, function() use ($script, $output)
					{
						if ($output->getMode() != 'minimal')
						{
							$output->addLine("Running '{$script}'");
						}
						shell_exec(escapeshellcmd($script));
					});
				}
			}
		}

		// Reset the output stored on the application
		$this->app->forget('output');
		$this->app->set('output', $output);

		return $response;
	}
66680
public function postRequestAsync( Request $request ) {
		$promise = $this->getClient()->requestAsync(
			'POST',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, $this->getPostRequestEncoding( $request ) )
		);

		return $promise->then( function ( ResponseInterface $response ) {
			return call_user_func( [ $this, 'decodeResponse' ], $response );
		} );
	}
481099
public function send(Request $request)
    {
        $ch = curl_init($request->getUrl());
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod());
        curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders()));
        if (!is_null($request->getBody())) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getBody());
        }

        curl_setopt_array($ch, $request->getCurlOptions());

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FAILONERROR, false);
        curl_setopt($ch, CURLOPT_HEADER, true);

        list($status, $headers, $body) = HttpUtil::parseResponse(curl_exec($ch));

        return new Response(
            HttpUtil::parseStatus($status),
            HttpUtil::parseHeaders($headers),
            $body,
            curl_getinfo($ch)
        );
    }
1145697
public function send(Request $request): Response
    {
        $this->serialInterface->send($request->encode());
        return $this->receiveResponse($request->getTimeout());
    }
875365
public function handle(Request $request)
    {
        try {
            $restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
            $restResponse = $this->adapter->processRequest($restRequest);
        } catch (\Exception $e) {
            if (true === $this->debugEnabled()) {
                throw $e;
            }
            $restResponse = $this->adapter->handleException($e);
        }
        return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
    }
71422
public function detect(Request $request)
	{
		if ($request->isMethod('post')) {
			return $request->request->get($this->parameterName);
		}

		return $request->query->get($this->parameterName);
	}
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;
        }
    }
736124
public function postAction(Request $request)
    {
        $type = 'page';
        $language = $this->getLanguage($request);
        $action = $request->get('action');

        $this->checkActionParameterSecurity($action, $language);

        $document = $this->getDocumentManager()->create($type);
        $formType = $this->getMetadataFactory()->getMetadataForAlias($type)->getFormType();

        $this->persistDocument($request, $formType, $document, $language);
        $this->handleActionParameter($action, $document, $language);
        $this->getDocumentManager()->flush();

        $context = new Context();
        $context->setGroups(['defaultPage']);

        return $this->handleView($this->view($document)->setContext($context));
    }
320816
protected function processPost(Request $request)
    {
        $resource = $this->getResourceManager()->createNewInstance();
        return $this->processAction($request, 'POST', $resource);
    }
234684
public function addAction(Request $request)
    {
        $resource = $this->mapper->create($this->validateRequestParameters($request));

        return new Response('', 201, array('Location' => $this->mapper->generateReadUrl($resource)));
    }