performs sending the request

@param RequestInterface $request

@throws Exception\ClientException
@throws Exception\RequestException
@return ResponseInterface
@author Daniel Wendlandt
978412
public function send(RequestInterface $request)
    {
        if (!RequestMethods::isAllowed($request->getMethod())) {
            throw new RequestException('request method is not allowed');
        }

        $transportRequest = $this->transport->createRequest($request->getMethod());
        $transportRequest->setPath($this->generatePath($request));
        $transportRequest = $this->setBody($transportRequest, $request->getBody());
        $transportRequest = $this->setQueryParameters($transportRequest, $request->getParameters());

        try {
            $transportResponse = $this->transport->send($transportRequest);
        } catch (TransportLayerException $exception) {
            $clientException = new ClientException($exception->getMessage(), $exception->getCode(), $exception);
            throw $clientException;
        }

        $rawData = (string)$transportResponse->getBody();

        /** @var Response $response */
        $response = $request->createResponse($rawData, $request->getSerializer(), $request->getSerializerParams());
        $supportedClass = $request->getSupportedClass();

        $this->mangleSupportedClass($response, $supportedClass);

        return $response;
    }
1021944
public function setRequest(\Psr\Http\Message\RequestInterface $request) : \Psr\Http\Message\RequestInterface
    {
        return $this->request = $request;
    }
1316945
private function query(RequestInterface $request)
    {
        return $this->client->send($request, array_merge(
            [RequestOptions::HTTP_ERRORS => false],
            $this->clientOptions
        ));
    }
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;
	}
1322157
protected function onSuccess(RequestInterface $request)
    {
        return function ($response) use ($request) {
            $this->log($request, $response);
            return $response;
        };
    }
851850
protected function sendRequest(RequestInterface $request, $responseClass)
    {
        if (!in_array(ApiResponseInterface::class, class_implements($responseClass))) {
            throw new \InvalidArgumentException('The response class must implement "'.ApiResponseInterface::class.'".');
        }

        $body = $this->serializer->serialize($request, 'json');
        $response = $this->transport->sendRequest($body);

        /** @var ApiResponseInterface $apiResponse */
        $apiResponse = $this->serializer->deserialize($response, $responseClass, 'json');
        if ($apiResponse->getResponse() !== null && $apiResponse->getResponse()->hasErrors()) {
            throw new ApiResponseException(
                sprintf('Error calling "%s"', $request->getService()),
                $apiResponse->getResponse()->getErrors()
            );
        }

        return $apiResponse;
    }
1199334
public function sendRequest(RequestInterface $request):ResponseInterface{
		$uri     = $request->getUri();
		$method  = $request->getMethod();
		$headers = $this->getRequestHeaders($request);

		$body    = \in_array($method, ['DELETE', 'PATCH', 'POST', 'PUT'], true)
			? $request->getBody()->getContents()
			: null;

		$context = \stream_context_create([
			'http' => [
				'method'           => $method,
				'header'           => $headers,
				'content'          => $body,
				'protocol_version' => '1.1',
				'user_agent'       => $this->options->user_agent,
				'max_redirects'    => 0,
				'timeout'          => 5,
			],
			'ssl' => [
				'cafile'              => $this->options->ca_info,
				'verify_peer'         => $this->options->ssl_verifypeer,
				'verify_depth'        => 3,
				'peer_name'           => $uri->getHost(),
				'ciphers'             => 'HIGH:!SSLv2:!SSLv3',
				'disable_compression' => true,
			],
		]);

		$requestUri = (string)$uri->withFragment('');

		\set_error_handler(function ($severity, $msg, $file, $line){
			throw new \ErrorException($msg, 0, $severity, $file, $line);
		});

		try{
			$responseBody    = \file_get_contents($requestUri, false, $context);
			$responseHeaders = $this->parseResponseHeaders(\get_headers($requestUri, 1, $context));
		}
		catch(\Exception $e){
			$this->logger->error('StreamClient error #'.$e->getCode().': '.$e->getMessage());

			throw new ClientException($e->getMessage(), $e->getCode());
		}

		\restore_error_handler();

		$response = $this->responseFactory
			->createResponse($responseHeaders['statuscode'], $responseHeaders['statustext'])
			->withProtocolVersion($responseHeaders['httpversion'])
		;

		$response->getBody()->write($responseBody);
		$response->getBody()->rewind();

		return $response;
	}
842649
public function handle(RequestInterface $request): RequestInterface
    {
        if ($this->token === '' || $this->key === '') {
            throw new AuthorizationException('Could not create api token, missing or empty arguments');
        }
        return $request->withHeader($this->key, $this->token);
    }
1294042
public function submit(RequestInterface $request)
    {
        $response = $this->browser->submit(
            $this->options['host'] . $request->getPath(),
            $request->getData(),
            $request->getMethod());

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

            return $response;
        };
    }
1303720
public function send(RequestInterface $request)
    {
        /** @var CurlTransport $transport */
        $transport = $this->getTransport();

        $this->tasks[] = [
            'handle' => $handle = $transport->createHandle($request),
            'promise' => $promise = new Promise()
        ];

        curl_multi_add_handle($this->getMainHandle(), $handle);

        return $promise;
    }
1371067
public function request(RequestInterface $request)
    {
        $uri = $request->getUri()
            ->withPath('')
            ->withQuery('')
            ->withFragment('');

        $uri = $uri . $request->getRequestTarget();

        $request = $request->withRequestTarget($uri);

        return $this->doRequest($request);
    }
364042
public function onRequest( RequestInterface $request ) {
        $localizedUri = Uri::withQueryValue( $request->getUri(), 'lang', $this->getEndpoint()->getLang() );
        return $request->withUri($localizedUri);
    }
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']);
            }
        }
    }
1142472
public function call(RequestInterface $request)
    {
        $this->checkEndpoint();

        $ch = curl_init();

        // cURL options
        $options = array(
            CURLOPT_URL            => $this->getEndpoint(),
            CURLOPT_HEADER         => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => http_build_query($request->getParameters()),
        );
        curl_setopt_array($ch, $options);

        $response = curl_exec($ch);

        $curlErrorNumber = curl_errno($ch);
        $curlErrorMessage = curl_error($ch);
        $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if ($curlErrorNumber > 0 || !in_array($responseCode, array(0, 200, 201, 204))) {
            throw new \RuntimeException('cUrl returns some errors (cURL errno '.$curlErrorNumber.'): '.$curlErrorMessage.' (HTTP Code: '.$responseCode.')');
        }

        curl_close($ch);

        return $response;
    }
508968
public function execute(RequestInterface $request): ResponseInterface
    {
        $this->supports($request);

        if ($request instanceof InputInterface) {
            $request->validate();
        }

        $client = $this->getClient();

        $data = array_replace($request->toArray(), [
            'carrier' => $client->getCarrier(),
            'key'     => $client->getKey(),
        ]);

        $response = $client->call($this->getMethodName(), $data);

        return $this->parseResponse($response->getBody()->getContents());
    }
287343
public function sendRequest(RequestInterface $request): void
    {
        $requestId = $this->getRequestId($request);
        $this->pendingRequests[$requestId] = $this->createPromiseForRequest($request, true);
    }