PHP's get_headers() accepts a stream context as its third argument. On PHP 8, a header check for an HTTP URL can carry its own proxy configuration:

$context = stream_context_create([
    'http' => [
        'proxy' => 'tcp://proxy.example.net:8080',
        'request_fulluri' => true,
        'method' => 'HEAD',
        'follow_location' => 0,
        'timeout' => 10,
    ],
]);

$headers = get_headers('http://example.net/file.zip', false, $context);
if ($headers === false) {
    throw new RuntimeException('Header request failed');
}

The proxy is a TCP endpoint for the HTTP stream wrapper. Replace its placeholder host and port with an unauthenticated candidate from the HTTP proxy list for this public HTTP check. request_fulluri supplies the complete destination URI in the HTTP request line, as expected by many forward proxies. This context belongs to this call; it does not change the default context used by other URL reads.

Despite the function's name, its default request method is GET. The explicit HEAD method asks the server for response metadata without the corresponding response body. A server can reject HEAD or handle it differently, so a successful header check is not proof that a later download will succeed.

Here, redirect following is disabled to inspect the first response. A Location header and a redirect status are then useful results rather than an instruction to fetch another URL. If the check should follow redirects, change that policy deliberately and account for the additional response headers.

The false argument keeps an indexed header array. Use true when associative parsing is more useful.

ХӀокхунах тера йаззамаш