Nextcloud PHP API (master)

CheckServerResponseTrait

Common trait for setup checks that need to use requests to the same server and check the response

Tags
since
31.0.0

Table of Contents

Properties

$clientService  : IClientService
$config  : IConfig
$logger  : LoggerInterface
$urlGenerator  : IURLGenerator

Methods

getTestUrls()  : array<int, string>
Get all possible URLs that need to be checked for a local request test.
runRequest()  : Generator<int, IResponse>
Run a HTTP request to check header
serverConfigHelp()  : string
Common helper string in case a check could not fetch any results
getRequestOptions()  : array<string|int, mixed>
Get HTTP client options
normalizeUrl()  : string
Strip a trailing slash and remove the webroot if requested.

Properties

Methods

getTestUrls()

Get all possible URLs that need to be checked for a local request test.

protected getTestUrls(string $url[, bool $isRootRequest = false ]) : array<int, string>

This takes all trusted_domains and the CLI overwrite URL into account.

Parameters
$url : string

The absolute path (absolute URL without host but with web-root) to test starting with a /

$isRootRequest : bool = false

Set to remove the web-root from URL and host (e.g. when requesting a path in the domain root like '/.well-known')

Tags
since
31.0.0
Return values
array<int, string>

List of possible absolute URLs

runRequest()

Run a HTTP request to check header

protected runRequest(string $method, string $url[, array{ignoreSSL?: bool, httpErrors?: bool, options?: array} $options = [] ][, bool $isRootRequest = false ]) : Generator<int, IResponse>
Parameters
$method : string

The HTTP method to use

$url : string

The absolute path (URL with webroot but without host) to check, can be the output of IURLGenerator

$options : array{ignoreSSL?: bool, httpErrors?: bool, options?: array} = []

HTTP client related options, like [ // Ignore invalid SSL certificates (e.g. self signed) 'ignoreSSL' => true, // Ignore requests with HTTP errors (will not yield if request has a 4xx or 5xx response) 'httpErrors' => true, // Additional options for the HTTP client (see IClient) 'options' => [], ]

$isRootRequest : bool = false

If set the webroot is removed from URLs to make the request target the host's root. Example usage are the /.well-known URLs in the root path.

Tags
since
31.0.0
Return values
Generator<int, IResponse>

serverConfigHelp()

Common helper string in case a check could not fetch any results

protected serverConfigHelp() : string
Tags
since
31.0.0
Return values
string

getRequestOptions()

Get HTTP client options

private getRequestOptions(bool $ignoreSSL, bool $httpErrors) : array<string|int, mixed>
Parameters
$ignoreSSL : bool

If set SSL errors are ignored (e.g. self-signed certificates)

$httpErrors : bool
Tags
since
31.0.0
Return values
array<string|int, mixed>

normalizeUrl()

Strip a trailing slash and remove the webroot if requested.

private normalizeUrl(string $url, bool $removeWebroot) : string
Parameters
$url : string

The URL to normalize. Should be an absolute URL containing scheme, host and optionally web-root.

$removeWebroot : bool

If set the web-root is removed from the URL and an absolute URL with only the scheme and host (optional port) is returned

Tags
since
31.0.0
Return values
string

        
On this page

Search results