Read API

@param \nv\semtools\Common\RequestInterface $request

@return uClassify\UclassifyResponse
@throws \InvalidArgumentException
513267
public function read(RequestInterface $request)
    {
        if (!$request instanceof UclassifyRequest) {
            throw new \InvalidArgumentException("Expected instance of UclassifyRequest, got ".get_class($request));
        }
        $this->request = $request;

        return $this->executeRequest();
    }
1094707
public function read(Request $request)
    {
        if (!$request->cookies->has($this->cookieSettings->getName())) {
            return null;
        }

        return $this->createCookieWithValue(
            $request->cookies->get($this->cookieSettings->getName())
        );
    }
55721
public function execute(RequestInterface $request)
    {
        $httpRequest = $this->httpRequestBuilder->build($request);

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

        return $this->resultBuilderEngine->build($request, $httpResponse);
    }
881814
private function read(ServerRequestInterface $request, string $file): ResponseInterface
    {
        $resource = $this->filesystem->readStream($file);

        if ($resource === false) {
            throw new RuntimeException(sprintf('Unable to read the file "%s"', $file)); //@codeCoverageIgnore
        }

        $response = $this->createResponse()->withBody($this->createStreamFromResource($resource));

        return self::range($response, $request->getHeaderLine('Range'));
    }
461109
public function execute(RequestInterface $request): RequestInterface
    {
        if ($request->getUri()->getPath() === self::ENDPOINT_INSTALLATION) {
            return $request;
        } else {
            $signature = $this->determineRequestSignature(
                $request->getUri(),
                $request->getMethod(),
                $request->getBody()->getContents(),
                $request->getHeaders()
            );

            return $request->withHeader(self::HEADER_CLIENT_SIGNATURE, $signature);
        }
    }
149003
private function getRootFilter(RequestInterface $request)
    {
        $filter = null;

        if ($request->getFilter()) {
            $filter = $this->queryBuilder->buildQuery($request->getFilter());
        }

        return $filter;
    }
465230
protected function doRequest(RequestInterface $request)
    {
        $ch = $this->createHandle($request);

        // Execute the request and close the connection.
        $content = curl_exec($ch);

        $error = curl_error($ch);

        if (!$this->getOption('allow_empty_result', false) && !trim((string) $content)) {
            // Error but nothing from cURL? Create our own
            $error = $error ?: 'No HTTP response received';

            throw new HttpRequestException($error, curl_errno($ch));
        }

        if (!$this->getOption('ignore_curl_error', false) && $error !== '') {
            throw new HttpRequestException($error, curl_errno($ch));
        }

        // Get the request information.
        $info = curl_getinfo($ch);

        // Close the connection.
        curl_close($ch);

        return $this->getResponse($content, $info);
    }
697177
private function scanIps(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $ips = [];

        if ($this->remote) {
            $ips[] = file_get_contents('http://ipecho.net/plain');
        }

        foreach ($this->headers as $name) {
            $header = $request->getHeaderLine($name);

            if (!empty($header)) {
                foreach (array_map('trim', explode(',', $header)) as $ip) {
                    if ((array_search($ip, $ips) === false) && filter_var($ip, FILTER_VALIDATE_IP)) {
                        $ips[] = $ip;
                    }
                }
            }
        }

        if (!empty($server['REMOTE_ADDR']) && filter_var($server['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
            $ips[] = $server['REMOTE_ADDR'];
        }

        return $ips;
    }
1106080
public function readAll(Request $request)
    {
        $user = $request->user();
        $user->unreadNotifications()->update(['read_at' => now()]);
        return $this->sendResponse(true, '');
    }
1102872
private function deEncodeRequestUrl(RequestInterface $request)
    {
        $query = $request->getUri()->getQuery();
        $decodedQuery = rawurldecode($query);

        $request->getUri()->withQuery($decodedQuery);

        return $request;
    }
856165
public static function fromPsrRequest(RequestInterface $request) {
		if (!$request->hasHeader('C-AAUID') || !$request->hasHeader('C-Access-Token'))
			return null;

		$context = new AccountContext(
			new IRI('aauid:'.$request->getHeaderLine('C-AAUID')),
				$request->getHeaderLine('C-Access-Token'));

		$context->parsePsrRequest($request);

		return $context;
	}
693518
private function doSendRequest(RequestInterface $request)
    {
        try {
            $response = $this->getHttpClient()->sendRequest($request);
        } catch (HttpTransferException $e) {
            throw new TransferException(
                $e->getMessage(),
                $request,
                $e instanceof HttpException ? $e->getResponse() : null
            );
        }

        if ($response->getStatusCode() >= 400) {
            throw new InvalidResponseException('Bad response status code.', $request, $response);
        }

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

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

        $data = json_decode($rawData, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new InvalidResponseException('Could not decode the response.', $request, $response);
        }

        return $data;
    }
106025
public function applyToRequest(RequestInterface $request)
    {
        $body = $this->streamFactory->createStream((string) $this->queryHelper);

        return $request
            ->withBody($body)
            ->withHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
663536
public function execute(RequestInterface $request): RequestInterface
    {
        if (is_null($this->sessionToken)) {
            return $request;
        } else {
            return $request->withHeader(
                self::HEADER_CLIENT_AUTHENTICATION,
                [$this->sessionToken->getToken()]
            );
        }
    }
882654
public function browseAction(Request $request)
    {
        $response = $this->convertResourceToPlainText(
            $request->getRequestFormat('xml'),
            $this->mapper->getCollection()
        );

        return new Response($response);
    }
1006845
public function getParsedResponse(RequestInterface $request)
    {
        try {
            $response = $this->getResponse($request);
        } catch (BadResponseException $e) {
            $response = $e->getResponse();
        }

        $parsed = $this->parseResponse($response);

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

        return $parsed;
    }
913421
public function send(RequestInterface $request)
    {
        $apiResponse = null;

        try {
            $apiResponse = $this->loadResponse($request);

            if ($apiResponse->ok()) {
                return $apiResponse;
            } else {
                throw new Exception('Response has unsuccessful status');
            }
        } catch (Exception $e) {
            // The following means that request failed completely
            if (empty($apiResponse)) {
                $apiResponse = new ApiResponse($request);
            }

            throw new ApiException($apiResponse, $e);
        }
    }