Gets the digest headers from the request/environment.

@param \Cake\Http\ServerRequest $request Request object.
@return array|bool Array of digest information.
170866
protected function _getDigest(ServerRequest $request)
    {
        $digest = $request->getEnv('PHP_AUTH_DIGEST');
        if (empty($digest) && function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') {
                $digest = substr($headers['Authorization'], 7);
            }
        }
        if (empty($digest)) {
            return false;
        }

        return $this->parseAuthData($digest);
    }
942546
private function detectFromExtension(ServerRequestInterface $request)
    {
        $extension = \strtolower(\pathinfo($request->getUri()->getPath(), PATHINFO_EXTENSION));

        if (empty($extension)) {
            return null;
        }

        foreach ($this->formats as $format => $data) {
            if (\in_array($extension, $data['extension'], true)) {
                return $format;
            }
        }

        return null;
    }
911099
protected function _pluginCondition(ServerRequest $request)
    {
        if ($request->getParam('plugin') !== null) {
            return [$this->getAlias() . '.plugin' => $request->getParam('plugin')];
        }

        return [$this->getAlias() . '.plugin IS NULL'];
    }
120697
protected function _getDigest(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $digest = empty($server['PHP_AUTH_DIGEST']) ? null : $server['PHP_AUTH_DIGEST'];
        if (empty($digest) && function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') {
                $digest = substr($headers['Authorization'], 7);
            }
        }
        if (empty($digest)) {
            return null;
        }

        return $this->parseAuthData($digest);
    }
259242
public static function getPreferredFormat(ServerRequestInterface $request)
    {
        $acceptTypes = $request->getHeader('accept');

        if (count($acceptTypes) > 0) {
            $acceptType = $acceptTypes[0];

            // As many formats may match for a given Accept header, let's try to find the one that fits the best
            $counters = [];
            foreach (self::$formats as $format => $values) {
                foreach ($values as $value) {
                    $counters[$format] = isset($counters[$format]) ? $counters[$format] : 0;
                    $counters[$format] += intval(strpos($acceptType, $value) !== false);
                }
            }

            // Sort the array to retrieve the format that best matches the Accept header
            asort($counters);
            end($counters);
            return key($counters);
        }

        return 'html';
    }
1222718
public function verifyRequest($request)
    {
        $this->getVersion($request);
        $consumer = $this->getConsumer($request);
        $token = $this->getToken($request, $consumer, "access");
        $this->checkSignature($request, $consumer, $token);
        return array($consumer, $token);
    }
931449
protected function getContentAsArray(Request $request)
    {
        $content = json_decode($request->getContent(), true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new BadRequestException();
        }

        if ($content === null) {
            return [];
        }

        return $content;
    }
685630
private function getRequestBody(Request $request): array
    {
        $contentType = $request->headers->get('CONTENT_TYPE', '');
        $semicolonPosition = strpos($contentType, ';');

        if ($semicolonPosition !== false) {
            $contentType = substr($contentType, 0, $semicolonPosition);
        }

        try {
            switch ($contentType) {
                case 'application/vnd.api+json':
                    return $this->serializer->decode($request->getContent(), 'jsonapi');
                case 'application/json':
                    return $request->request->all();
            }
        } catch (InvalidArgumentException | UnexpectedValueException $exception) {
            throw new BadRequestHttpException($exception->getMessage());
        }

        throw new UnsupportedMediaTypeHttpException(sprintf('The Content-Type "%s" is unsupported.', $contentType));
    }
23052
protected function getToken(ServerRequestInterface $request)
    {
        $token = $this->getTokenFromHeader($request, $this->getConfig('header'));
        if ($token === null) {
            $token = $this->getTokenFromQuery($request, $this->getConfig('queryParam'));
        }

        $prefix = $this->getConfig('tokenPrefix');
        if ($prefix !== null && is_string($token)) {
            return $this->stripTokenPrefix($token, $prefix);
        }

        return $token;
    }
1146438
protected function parseDigest($digest, HttpRequest $request)
	{
		$required = [
			'nonce' => true,
			'username' => true,
			'response' => true,
			'cnonce' => true,
			'nc' => true
		];
	
		$tmp = [];
		$data = [];
	
		@preg_match_all("'(\w+)\s*=\s*(?:(?:\"((?:(?<!\\\\)[^\"])+)\")|([^,]+),)'U", $digest, $tmp, PREG_SET_ORDER);
	
		foreach($tmp as $m)
		{
			$data[$m[1]] = array_key_exists(3, $m) ? trim(trim($m[3]), '"') : trim(trim($m[2]), '"');
	
			unset($required[$m[1]]);
		}
		
		if(!empty($data['username']))
		{
			if(false !== strpos($data['username'], '\\\\'))
			{
				$tmp = explode('\\\\', $data['username']);
				
				$username = trim(array_pop($tmp), '"');
				$domain = trim(implode('\\\\', $tmp), '"');
				
				if($domain === $request->getHost())
				{
					$data['username'] = $username;
					$data['msdomain'] = $domain;
				}
			}
		}

		return (count($required) > 0) ? [] : $data;
	}
550518
private function getUriContext(Request $request): array
    {
        $context = $request->query->get('ngbmContext');
        $context = is_array($context) ? $context : [];

        if (!$this->uriSigner->check($this->getUri($request))) {
            return [];
        }

        return $context;
    }
969892
private function getTokenFromQuery(ServerRequestInterface $request): ?string
    {
        $query_params = $request->getQueryParams();

        return $this->getAccessTokenFromParameters($query_params);
    }
540401
public function get_items( $request ) {
		$data = array();
		$statuses = get_post_stati( array( 'internal' => false ), 'object' );
		$statuses['trash'] = get_post_status_object( 'trash' );
		foreach ( $statuses as $slug => $obj ) {
			$ret = $this->check_read_permission( $obj );
			if ( ! $ret ) {
				continue;
			}
			$status = $this->prepare_item_for_response( $obj, $request );
			$data[ $obj->name ] = $this->prepare_response_for_collection( $status );
		}
		return rest_ensure_response( $data );
	}
293659
private function getAuthenticationHeaders(HttpRequest $request) {
		$timestamp = time();
		$version = '1';
		$path = $request->getPath();
		$securedData = $version . '|' . $this->userId . '|' . $timestamp . '|' . $request->getMethod() . '|' . $path;

		$headers = array();
		$headers['x-mac-version'] = $version;
		$headers['x-mac-userid'] = $this->userId;
		$headers['x-mac-timestamp'] = $timestamp;
		$headers['x-mac-value'] = $this->calculateHmac($securedData);
		return $headers;
	}
1076317
protected function parse(ServerRequestInterface $request): array
    {
        $body = $request->getBody()->getContents();
        if ($body === '') {
            return [];
        }

        $parsedJson = \json_decode($body, true, $this->decodeDepth, $this->decodeOptions);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new DomainException(json_last_error_msg(), json_last_error());
        }

        return $parsedJson;
    }
470720
protected function getRequestBody(ServerRequestInterface $request) : string
    {
        if ($decryptedBody = $request->getAttribute('ncryptf-decrypted-body', false)) {
            return $decryptedBody;
        }

        return $request->getBody()->getContents();
    }
73240
protected function _getData(ServerRequestInterface $request)
    {
        $fields = $this->_config['fields'];
        $body = $request->getParsedBody();

        $data = [];
        foreach ($fields as $key => $field) {
            if (!isset($body[$field])) {
                return null;
            }

            $value = $body[$field];
            if (!is_string($value) || !strlen($value)) {
                return null;
            }

            $data[$key] = $value;
        }

        return $data;
    }