phpEZ v0.4.2

HTTPSrv
in package

FinalYes

HTTP server utility class for request context.

Provides methods to retrieve client IP addresses, accounting for reverse proxies. Designed as a static utility class; cannot be instantiated.

Tags
subpackage

http

Table of Contents

Properties

$proxyHeader  : string|null

Methods

behindRevProxy()  : void
Set the HTTP header to trust for client IP detection behind reverse proxies.
remote_addr()  : string
Get the remote client IP address, accounting for proxies.
__construct()  : mixed

Properties

$proxyHeader

private static string|null $proxyHeader = 'REMOTE_ADDR'

Methods

behindRevProxy()

Set the HTTP header to trust for client IP detection behind reverse proxies.

public static behindRevProxy(string $header) : void
Parameters
$header : string

The HTTP header to use for client IP detection, must be in $_SERVER.

remote_addr()

Get the remote client IP address, accounting for proxies.

public static remote_addr() : string

Checks HTTP headers in order of reliability to determine the actual client IP

Tags
throws
HTTPException

If no IP address can be determined.

Return values
string —

The client IP address.

__construct()

private __construct() : mixed
On this page

Search results