Sends a request and returns the parsed response.

@param  RequestInterface $request
@return mixed
199357
public function getResponse(RequestInterface $request)
    {
        $response = $this->sendRequest($request);
        $parsed = $this->parseResponse($response);

        $this->checkResponse($response, $parsed);

        return $parsed;
    }
33878
protected function setAllowance(RequestInterface $request)
    {
        return function (ResponseInterface $response) use ($request) {
            $this->provider->setRequestAllowance($request, $response);

            return $response;
        };
    }
55721
public function execute(RequestInterface $request)
    {
        $httpRequest = $this->httpRequestBuilder->build($request);

        $httpResponse = $this->transport->execute($httpRequest);

        return $this->resultBuilderEngine->build($request, $httpResponse);
    }
129958
protected function handleRequest(RequestInterface $request)
    {
        if (!$this->getOption('batch', false)) {
            $response = $this->client->send($request);
            return $this->normalizeResponse($response);
        }
        $this->requests[] = $request;
    }
952685
public function build(RequestInterface $request): ResponseInterface
    {
        return $this->responseFactory->createResponse(
            $this->getMockStatusForRequest($request),
            '',
            $this->getMockHeadersForRequest($request),
            $this->getMockBodyForRequest($request)
        );
    }
79137
public function send(RequestInterface $request)
	{
		$response = parent::send($request);

		if ($response->getStatusCode() == 202)
		{
			if (($responseBody = json_decode($response->getBody(), true)) && isset($responseBody['href']))
			{
				$operation = new Uri($responseBody['href']);

				if ( ! $operation->getQuery())
				{
					$responseBody['operation'] = substr(strrchr($operation->getPath(), '/'), 1);
					$stream = new Stream('php://temp', 'w');
					$stream->write(json_encode($responseBody));
					$this->addOperation($responseBody['operation']);

					return $response->withBody($stream);
				}
			}
		}

		return $response;
	}
723503
protected function sendRequest(RequestInterface $request)
    {
        $response = $this->client->send($request);
        /* @var \Psr\Http\Message\ResponseInterface $response */

        return json_decode($response->getBody(), true);
    }
1068465
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $body = $request->getParsedBody();

        $method = strtoupper($body[self::METHOD_INPUT_KEY] ?? $request->getMethod());

        $request = $request->withMethod($method);

        $this->match = $this->adapter->match($request);

        return $this->match->handle($request);
    }
625296
protected function sendRequest(RequestInterface $request): ResponseInterface
    {
        $data = $request->getData();

        $event = new SendPaymentRequestEvent([
            'requestData' => $data
        ]);

        // Raise 'beforeSendPaymentRequest' event
        $this->trigger(self::EVENT_BEFORE_SEND_PAYMENT_REQUEST, $event);

        // We can't merge the $data with $modifiedData since the $data is not always an array.
        // For example it could be a XML object, json, or anything else really.
        if ($event->modifiedRequestData !== null) {
            return $request->sendData($event->modifiedRequestData);
        }

        return $request->send();
    }
1371934
private function createRequest(RequestInterface $request)
    {
        $options = [
            'exceptions' => false,
            'allow_redirects' => false,
        ];

        $options['version'] = $request->getProtocolVersion();
        $options['headers'] = $request->getHeaders();
        $body = (string) $request->getBody();
        $options['body'] = '' === $body ? null : $body;

        return $this->client->createRequest(
            $request->getMethod(),
            (string) $request->getUri(),
            $options
        );
    }
712730
private function sendRequest(RequestInterface $request)
    {
        $request->getParams()->set('redirect.max', $this->getMaxRedirects());

        try {
            $response = $request->send();
        } catch (\Exception $e) {
            throw HttpAdapterException::cannotFetchUrl($request->getUrl(), $this->getName(), $e->getMessage());
        }

        return $this->createResponse(
            $response->getStatusCode(),
            $request->getUrl(),
            $response->getHeaders()->toArray(),
            $response->getBody(true),
            $response->getEffectiveUrl()
        );
    }
242701
public function notFoundResponse(RequestInterface $request)
    {
        if ($this->missingChain) {
            return $this->missingChain->execute(
                [$this->server, $request],
                $this->middlewares
            );
        }
        return Response::make('<html><head><title>404 Not Found</title></head><body bgcolor="white"><h1>404 Not Found</h1></body></html>', 404);
    }
11158
protected function send(Request $request)
    {
        try {
            $response = $this->client->send($request);
        } catch (ClientException $e) {
            $response = $e->getResponse();
        } catch (ServerException $e) {
            $response = $e->getResponse();
        }

        return $response;
    }
311684
public function processRequest(RequestInterface $request)
    {
        $this->response = $this->communicator->getResponse($request);

        return $this->response;
    }
311393
public function handle(RequestInterface $request)
    {
        $response = $request->send();
        $headers = $response->getHeaders()->getAll();
        $body = $response->getBody(true);
        $statusCode = $response->getStatusCode();

        $symfonyHeaders = array();

        foreach ($headers as $keys) {
            /**
             * Transfer-Encoding type chunked is not suported by symfony response
             */
            if($keys->getName() == "Transfer-Encoding" && $keys->__toString() === 'chunked'){
                continue;
            }
            $symfonyHeaders[$keys->getName()] = $keys->__toString();
        }

        return new Response($body,$statusCode,$symfonyHeaders);
    }
1238166
public function updateRequestFromTransfer(RequestInterface $request)
    {
        if (!$request->getResponse()) {
            return;
        }

        // Update the transfer stats of the response
        $request->getResponse()->setInfo($this->getInfo());

        if (!$log = $this->getStderr(true)) {
            return;
        }

        // Parse the cURL stderr output for outgoing requests
        $headers = '';
        fseek($log, 0);
        while (($line = fgets($log)) !== false) {
            if ($line && $line[0] == '>') {
                $headers = substr(trim($line), 2) . "\r\n";
                while (($line = fgets($log)) !== false) {
                    if ($line[0] == '*' || $line[0] == '<') {
                        break;
                    } else {
                        $headers .= trim($line) . "\r\n";
                    }
                }
            }
        }

        // Add request headers to the request exactly as they were sent
        if ($headers) {
            $parsed = ParserRegistry::getInstance()->getParser('message')->parseRequest($headers);
            if (!empty($parsed['headers'])) {
                $request->setHeaders(array());
                foreach ($parsed['headers'] as $name => $value) {
                    $request->setHeader($name, $value);
                }
            }
            if (!empty($parsed['version'])) {
                $request->setProtocolVersion($parsed['version']);
            }
        }
    }
1316945
private function query(RequestInterface $request)
    {
        return $this->client->send($request, array_merge(
            [RequestOptions::HTTP_ERRORS => false],
            $this->clientOptions
        ));
    }