From 93991225fe54ab59c7efe8702be9cf016f9beeef Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sat, 12 Feb 2022 22:51:42 +0100 Subject: [PATCH] Use curl_setopt_array and enable http2 for speeding up CURL requests --- src/MD_STD.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/MD_STD.php b/src/MD_STD.php index 8a5504d..7a3a562 100644 --- a/src/MD_STD.php +++ b/src/MD_STD.php @@ -296,14 +296,17 @@ final class MD_STD { $curl = \curl_init(); - \curl_setopt($curl, CURLOPT_URL, $url); - \curl_setopt($curl, CURLOPT_HEADER, false); - \curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $timeout); //timeout in seconds - \curl_setopt($curl, CURLOPT_TIMEOUT_MS, $timeout); //timeout in seconds - \curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); - // \curl_setopt($curl, CURLOPT_COOKIESESSION, true); - \curl_setopt($curl, CURLOPT_AUTOREFERER, true); - \curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2'); + \curl_setopt_array($curl, [ + CURLOPT_URL => $url, + CURLOPT_HEADER => false, + CURLOPT_CONNECTTIMEOUT_MS => $timeout, //timeout in seconds + CURLOPT_TIMEOUT_MS => $timeout, //timeout in seconds + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0, + // CURLOPT_COOKIESESSION => true, + CURLOPT_AUTOREFERER => true, + CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2', + ]); /* if (!file_exists(__DIR__ . '/../../curled.txt')) {