@param \Psr\Http\Message\RequestInterface $request

@throws \RuntimeException

@return array
429242
protected function getMockHeadersForRequest(RequestInterface $request): array
    {
        try {
            $file = $this->getMockFilePathForRequest($request, self::TYPE_HEADERS);

            return json_decode(file_get_contents($file), true);
        } catch (MockNotFoundException $e) {
            return [];
        }
    }
444690
protected function getCacheKey(RequestInterface $request): string
    {
        if ($this->key === null) {
            $this->key = $request->getMethod() . md5((string)$request->getUri());
        }
        return (string)$this->key;
    }
723503
protected function sendRequest(RequestInterface $request)
    {
        $response = $this->client->send($request);
        /* @var \Psr\Http\Message\ResponseInterface $response */

        return json_decode($response->getBody(), true);
    }
335301
public function send(Request $request)
    {
        $headers = array('Content-Type' => $request->getContentType());
        $content = $request->formatData();

        if ($this->hasSiteKey()) {
            $headers = array_merge($headers, array('x-atom-log-id' => $this->getSiteKey()));
        }

        try {
            $response = $this->getBrowser()->post($this->getAtomUri(), $headers, $content);
        } catch(\Exception $e) {
            throw new \RuntimeException($e->getMessage());
        }

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

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

        return $parsed;
    }
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
        );
    }
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());
    }
245600
private function doSearch(RequestInterface $request)
    {
        $searchRequest = [
            'index' => $request->getIndex(),
            'type'  => $request->getType(),
            'body'  => $this->requestMapper->buildSearchRequest($request),
        ];

        return $this->client->search($searchRequest);
    }
1316945
private function query(RequestInterface $request)
    {
        return $this->client->send($request, array_merge(
            [RequestOptions::HTTP_ERRORS => false],
            $this->clientOptions
        ));
    }
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;
    }
523494
private function userData(ServerRequestInterface $request): array
    {
        $data = [];

        foreach (self::DEFAULT_DATA as $key => $default) {
            $data[$key] = $request->getParsedBody()[$key] ?? $default;
        }

        return $data;
    }
664794
protected function processing(RequestInterface $request)
    {
        $key = sprintf(
            '%s?%s',
            $request->getUri()->getPath(),
            $request->getUri()->getQuery()
        );

        if ($request->getMethod() == 'GET' && isset($this->data[$key])) {
            return $this->data[$key];
        }

        return null;
    }
371685
public function onRequest( RequestInterface $request ) {
        $schema = $this->getEndpoint()->getSchema();

        return $request->withHeader( 'X-Schema-Version', $schema );
    }
1156285
protected function getParametersToSign(RequestInterface $request)
    {
        $params         = $this->getOAuthParameters($request);

        if ($request->getHeader('Content-Type') === 'application/x-www-form-urlencoded') {
            $params = array_merge($params, $this->getContentAsParameters($request));
        }

        return $params;
    }
111475
private function cacheKeyFromRequest(RequestInterface $request)
    {
        $uri = $request->getUri();

        $queryStr = $uri->getQuery();
        if (!empty($queryStr)) {
            $queryArr = [];

            parse_str($queryStr, $queryArr);

            $queryArr = $this->parseIgnoredParams($queryArr);
            $queryStr = http_build_query($queryArr);

            $uri = $uri->withQuery($queryStr);
        }

        $cacheKey = 'request/' . $request->getMethod() . '/' . md5((string)$uri);
        return $cacheKey;
    }
1319337
protected function getRequestedHeadersInLowerCase(RequestInterface $request): array
	{
		$requestHeaders = $request->getHeaderLine('Access-Control-Request-Headers');
		if ($requestHeaders === '') {
			return [];
		}

		// after explode header names might have spaces in the beginnings and ends...
		$requestHeaders = \explode(',', $requestHeaders);

		// ... so trim the spaces and convert values to lower case
		foreach ($requestHeaders as &$headerName) {
			$headerName = \strtolower(\trim($headerName));
		}

		return $requestHeaders;
	}
325303
public function decorate(RequestInterface $request)
    {
        return $request->withHeader($this->headerName, $this->requestIdProvider->getRequestId());
    }