final class HttpRequestInspector (View source)

Derives logging and content-negotiation metadata without reparsing proxy trust inputs.

Constants

private UNKNOWN

Methods

__construct(ResolvedRequestContext|null $context = null)

Uses the request-scoped trust result when security-sensitive metadata is requested.

string|null
clientIp(ServerRequestInterface $request)

Returns the verified client address, or null outside an initialized HTTP request scope.

string|null
string|null
anonymizedIp(ServerRequestInterface $request)

Masks the identifying suffix of the selected IPv4 or IPv6 client address.

string|null
bool
viaProxy(ServerRequestInterface $request)

Reports whether the verified immediate peer is an explicitly trusted proxy.

bool
string
forwardedFor(ServerRequestInterface $request)

Returns the verified client address for proxied requests, or an empty string otherwise.

string
string
userAgent(ServerRequestInterface $request)

Returns the request user-agent header line.

string
string|null
referer(ServerRequestInterface $request)

Returns the request's standard referrer value when present.

string|null
string
host(ServerRequestInterface $request)

Returns the allowlisted request host or an explicit unknown marker.

string
string
accept(ServerRequestInterface $request)

Returns the Accept header or an explicit unknown marker when it is absent.

string
bool
wantsJson(ServerRequestInterface $request)

Returns whether JSON is an explicitly preferred acceptable response representation.

bool
string
acceptLanguage(ServerRequestInterface $request)

Returns the raw Accept-Language header line.

string
bool
gzipAccepted(ServerRequestInterface $request)

Reports whether the request's encoding declaration contains gzip support.

bool
int
contentLength(ServerRequestInterface $request)

Returns a numeric Content-Length value or zero for missing and invalid input.

int
int
queryParamsCount(ServerRequestInterface $request)

Counts the request's parsed query parameters.

int
int
parsedBodyParamsCount(ServerRequestInterface $request)

Counts parsed body parameters when the body representation is an array.

int
string|null
requestId(ServerRequestInterface $request)

Resolves a request identifier from its header before consulting server parameters.

string|null
string
fingerprint(ServerRequestInterface $request)

Hashes selected normalized request traits into a stable privacy-reduced fingerprint.

string

Details

__construct

__construct(ResolvedRequestContext|null $context = null)

Uses the request-scoped trust result when security-sensitive metadata is requested.

Parameters

ResolvedRequestContext|null $context

clientIp

string|null clientIp(ServerRequestInterface $request)

Returns the verified client address, or null outside an initialized HTTP request scope.

Parameters

ServerRequestInterface $request

Return Value

string|null

anonymizedIp

string|null anonymizedIp(ServerRequestInterface $request)

Masks the identifying suffix of the selected IPv4 or IPv6 client address.

Parameters

ServerRequestInterface $request

Return Value

string|null

viaProxy

bool viaProxy(ServerRequestInterface $request)

Reports whether the verified immediate peer is an explicitly trusted proxy.

Parameters

ServerRequestInterface $request

Return Value

bool

forwardedFor

string forwardedFor(ServerRequestInterface $request)

Returns the verified client address for proxied requests, or an empty string otherwise.

Parameters

ServerRequestInterface $request

Return Value

string

userAgent

string userAgent(ServerRequestInterface $request)

Returns the request user-agent header line.

Parameters

ServerRequestInterface $request

Return Value

string

referer

string|null referer(ServerRequestInterface $request)

Returns the request's standard referrer value when present.

Parameters

ServerRequestInterface $request

Return Value

string|null

host

string host(ServerRequestInterface $request)

Returns the allowlisted request host or an explicit unknown marker.

Parameters

ServerRequestInterface $request

Return Value

string

accept

string accept(ServerRequestInterface $request)

Returns the Accept header or an explicit unknown marker when it is absent.

Parameters

ServerRequestInterface $request

Return Value

string

wantsJson

bool wantsJson(ServerRequestInterface $request)

Returns whether JSON is an explicitly preferred acceptable response representation.

This inspects only the Accept header. It does not infer a response format from the request Content-Type, an AJAX header, or an Accept wildcard alone.

Parameters

ServerRequestInterface $request

Return Value

bool

acceptLanguage

string acceptLanguage(ServerRequestInterface $request)

Returns the raw Accept-Language header line.

Parameters

ServerRequestInterface $request

Return Value

string

gzipAccepted

bool gzipAccepted(ServerRequestInterface $request)

Reports whether the request's encoding declaration contains gzip support.

Parameters

ServerRequestInterface $request

Return Value

bool

contentLength

int contentLength(ServerRequestInterface $request)

Returns a numeric Content-Length value or zero for missing and invalid input.

Parameters

ServerRequestInterface $request

Return Value

int

queryParamsCount

int queryParamsCount(ServerRequestInterface $request)

Counts the request's parsed query parameters.

Parameters

ServerRequestInterface $request

Return Value

int

parsedBodyParamsCount

int parsedBodyParamsCount(ServerRequestInterface $request)

Counts parsed body parameters when the body representation is an array.

Parameters

ServerRequestInterface $request

Return Value

int

requestId

string|null requestId(ServerRequestInterface $request)

Resolves a request identifier from its header before consulting server parameters.

Parameters

ServerRequestInterface $request

Return Value

string|null

fingerprint

string fingerprint(ServerRequestInterface $request)

Hashes selected normalized request traits into a stable privacy-reduced fingerprint.

Parameters

ServerRequestInterface $request

Return Value

string