From ff2d85b703bbdea270c7cf4611643ebeb69c3de3 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 22 Aug 2021 22:49:55 +0200 Subject: [PATCH] Initialize $curlOptions[CURLOPT_HTTPHEADER] outside of the checks --- src/Network/HTTPRequest.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Network/HTTPRequest.php b/src/Network/HTTPRequest.php index e33b0ed59..b08e91832 100644 --- a/src/Network/HTTPRequest.php +++ b/src/Network/HTTPRequest.php @@ -108,7 +108,7 @@ class HTTPRequest implements IHTTPRequest $curlOptions = []; if (!empty($opts['cookiejar'])) { - $curlOptions[CURLOPT_COOKIEJAR] = $opts["cookiejar"]; + $curlOptions[CURLOPT_COOKIEJAR] = $opts["cookiejar"]; $curlOptions[CURLOPT_COOKIEFILE] = $opts["cookiejar"]; } @@ -116,22 +116,18 @@ class HTTPRequest implements IHTTPRequest // $curlOptions[CURLOPT_FOLLOWLOCATION] =true; // $curlOptions[CURLOPT_MAXREDIRS] = 5; + $curlOptions[CURLOPT_HTTPHEADER] = []; + if (!empty($opts['accept_content'])) { - if (empty($curlOptions[CURLOPT_HTTPHEADER])) { - $curlOptions[CURLOPT_HTTPHEADER] = []; - } array_push($curlOptions[CURLOPT_HTTPHEADER], 'Accept: ' . $opts['accept_content']); } if (!empty($opts['header'])) { - if (empty($curlOptions[CURLOPT_HTTPHEADER])) { - $curlOptions[CURLOPT_HTTPHEADER] = []; - } $curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['header'], $curlOptions[CURLOPT_HTTPHEADER]); } $curlOptions[CURLOPT_RETURNTRANSFER] = true; - $curlOptions[CURLOPT_USERAGENT] = $this->getUserAgent(); + $curlOptions[CURLOPT_USERAGENT] = $this->getUserAgent(); $range = intval($this->config->get('system', 'curl_range_bytes', 0)); @@ -146,9 +142,6 @@ class HTTPRequest implements IHTTPRequest if (!empty($opts['headers'])) { $this->logger->notice('Wrong option \'headers\' used.'); - if (empty($curlOptions[CURLOPT_HTTPHEADER])) { - $curlOptions[CURLOPT_HTTPHEADER] = []; - } $curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['headers'], $curlOptions[CURLOPT_HTTPHEADER]); }