stream_context_create_options

Description

Filters the options that should be passed to the stream_context_create() function.

Parameters

$opts (array) (required) Options to pass to stream_context_create().

Example

$app = \Liten\Liten::getInstance();

function http_proxy_authentication($opts)
{
    $username = 'proxy_username';
    $password = 'proxy_password';
    
    $auth = base64_encode("$username:$password");
    
    $opts = [
        'http' => [
            'proxy' => 'tcp://127.0.0.1:8080',
            'request_fulluri' => true,
            'header' => "Proxy-Authorization: Basic $auth"
        ]
    ];
    
    return $opts;
}
$app->hook->add_filter('stream_context_create_options', 'http_proxy_authentication', 10, 1);

Change Log

Since 6.2.4

Source File

stream_context_create_options hook is located in app/src/functions/core-function.php.

See Also