From 7ceb3854cc8f071d264950522f33e5a04d333db1 Mon Sep 17 00:00:00 2001 From: Tom Broucke Date: Thu, 2 Nov 2023 12:26:55 +0100 Subject: [PATCH] added options to fetch function --- src/functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/functions.php b/src/functions.php index 651ad5423..d5ac354ca 100644 --- a/src/functions.php +++ b/src/functions.php @@ -933,7 +933,7 @@ function timestamp(): string * var_dump($info['http_code'], $result); * ``` */ -function fetch(string $url, string $method = 'get', array $headers = [], ?string $body = null, ?array &$info = null, bool $nothrow = false): string +function fetch(string $url, string $method = 'get', array $headers = [], ?string $body = null, ?array &$info = null, bool $nothrow = false, array $options = []): string { $url = parse($url); if (strtolower($method) === 'get') { @@ -950,5 +950,8 @@ function fetch(string $url, string $method = 'get', array $headers = [], ?string if ($body !== null) { $http = $http->body($body); } + foreach($options as $key => $value) { + $http = $http->setopt($key, $value); + } return $http->send($info); }