Format query parameters.

@param RequestInterface $request

@return string
429943
public function getFormattedQueryParameters(RequestInterface $request)
    {
        return $this->getString($this->getQueryParameters($request->getUri()->getQuery()));
    }
110930
protected static function getKey(RequestInterface $request)
    {
        // Generate headerline for the cache key. X- headers are ignored except those included in the Vary
        $vary = array_flip($request->getHeader('Vary'));
        $headerLine = implode('', array_map(
            [$request, 'getHeaderLine'],
            array_filter(
                array_keys($request->getHeaders()),
                function ($header) use ($vary) {
                    return (0 !== stripos($header, 'x-')
                        || array_key_exists($header, $vary)
                    );
                }
            )
        ));

        return $request->getMethod().'-'.$request->getUri().'-'.md5($headerLine);
    }
371685
public function onRequest( RequestInterface $request ) {
        $schema = $this->getEndpoint()->getSchema();

        return $request->withHeader( 'X-Schema-Version', $schema );
    }
870616
protected function getParameters(RequestInterface $request, ResponseInterface $response = null)
    {
        $params = [];
        $result = '';

        $keys = array_intersect($this->context, $this->availableParameters);

        foreach ($keys as $key) {
            switch ($key) {
                case 'method':
                    $result = $request->getMethod();
                    break;
                case 'url':
                    $result = $request->getUri()->__toString();
                    break;
                case 'request_version':
                    $result = $request->getProtocolVersion();
                    break;
                case 'response_version':
                    $result = $response ? $response->getProtocolVersion() : 'NULL';
                    break;
                case 'host':
                    $result = $request->getUri()->getHost();
                    break;
                case 'hostname':
                    $result = gethostname();
                    break;
                case 'status_code':
                    $result = $response ? $response->getStatusCode() : 'NULL';
                    break;
                case 'phrase':
                    $result = $response ? $response->getReasonPhrase() : 'NULL';
                    break;
            }

            $params[$key] = (string) $result ?: '';
        }

        return $params;
    }
259623
public function handle(RequestInterface $request): RequestInterface
    {
        return
            $request->withHeader(
                'Authorization',
                sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->user, $this->password)))
            );
    }
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;
	}
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
1307508
private function getCacheKey(RequestInterface $request)
    {
        return implode('|', [$request->getIndex(), $request->getType(), $request->getQueryText()]);
    }
1355326
private function parseFilters(TableInterface $table, Request $request)
    {
        $filters = [];

        $queryParams = $request->get($table->getFormId());

        foreach ($table->getAllFilters() as $filter) {
            if (isset($queryParams[$filter->getName()])) {
                $searchParamRaw = trim($queryParams[$filter->getName()]);
                if ($searchParamRaw != '') {
                    $filters[$filter->getName()] = $searchParamRaw;
                }
            }
        }

        return $filters;
    }
1230519
public function renderRequest(RequestInterface $request)
    {
        $return  = '';
        $return .= sprintf("URL:     %s\n", $request->getUri());
        $return .= sprintf("METHOD:  %s\n", $request->getMethod());

        if ($request->getHeaders()) {
            $return .= 'HEADERS:';
        }

        $indent = false;
        foreach ($request->getHeaders() as $name => $values) {
            if ($indent) {
                $return .= str_repeat(' ', 8);
            }

            $return .= sprintf(" %s: %s\n", $name, implode(', ', $values));
            $indent  = true;
        }

        if ($body = (string) $request->getBody()) {
            $return .= 'BODY:    ';

            switch ($request->getHeaderLine('Content-Type')) {
                case 'application/json':
                    $return .= json_encode(json_decode($body, true), JSON_PRETTY_PRINT);
                    break;
                default:
                    $return .= $body;
                    break;
            }

            $return .= "\n";
        }

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

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

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

        return $parsed;
    }
1294042
public function submit(RequestInterface $request)
    {
        $response = $this->browser->submit(
            $this->options['host'] . $request->getPath(),
            $request->getData(),
            $request->getMethod());

        return json_decode($response->getContent());
    }
276459
protected function getCacheKey(RequestInterface $request)
    {
        // Allow cache.key_filter to trim down the URL cache key by removing generate query string values (e.g. auth)
        if ($filter = $request->getParams()->get('cache.key_filter')) {
            $url = $request->getUrl(true);
            foreach (explode(',', $filter) as $remove) {
                $url->getQuery()->remove(trim($remove));
            }
        } else {
            $url = $request->getUrl();
        }

        return $this->keyPrefix . md5($request->getMethod() . ' ' . $url);
    }
15640
private function mapQueryToActionParameters(RouteEndpoint $route, RequestInterface $request) : array
    {
        $reflection = new ReflectionClass($route->getFullyQualifiedName());
        $method = $reflection->getMethod($route->getAction(true));
        $query = $request->getQuery();

        $mapper = [];
        foreach ($method->getParameters() as $parameter) {
            $defaultValue = null;
            if ($parameter->isDefaultValueAvailable()) {
                $defaultValue = $parameter->getDefaultValue();
            }

            $value = $query->get($parameter->getName(), $defaultValue);

            // We are missing a required parameter, so this is a bad request
            if ($value === null && !$parameter->allowsNull()) {
                throw HttpException::badRequest();
            }

            $mapper[$parameter->getName()] = $value;
        }

        return $mapper;
    }
179190
protected function authentication(RequestInterface $request)
	{
		$uri = $request->getUri();
		$key = http_build_query(['key' => $this->getAccessKey()], null, '&');

		if (strlen($uri->getQuery()) > 0)
		{
			$key = '&'.$key;
		}

		return $request->withUri($uri->withQuery($uri->getQuery().$key));
	}
64925
public function process(RequestInterface $request): bool
    {
        if (!$request->getMethod()->isGet()) {
            return false;
        }

        if ($request->getUrl()->getQueryString() === null) {
            return false;
        }

        return $this->doProcess($request->getQueryParameters());
    }