From 53fbd2a5a0215d9de28ca4da64743cbab3632b73 Mon Sep 17 00:00:00 2001 From: triatic <42704418+triatic@users.noreply.github.com> Date: Sat, 7 Sep 2019 17:32:06 +0100 Subject: [PATCH] [FacebookBridge] Prevent sending empty header (#1239) * [FacebookBridge] Prevent sending empty header When running in CLI mode, `getEnv('HTTP_ACCEPT_LANGUAGE')` returns `false`. In that case, don't send the `Accept-Language` header. --- bridges/FacebookBridge.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index ef3dc5a3..08b3a38a 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -142,7 +142,11 @@ class FacebookBridge extends BridgeAbstract { private function collectGroupData() { - $header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n"); + if(getEnv('HTTP_ACCEPT_LANGUAGE')) { + $header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE')); + } else { + $header = array(); + } $html = getSimpleHTMLDOM($this->getURI(), $header) or returnServerError('Failed loading facebook page: ' . $this->getURI()); @@ -505,7 +509,11 @@ EOD; // Retrieve page contents if(is_null($html)) { - $header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE')); + if(getEnv('HTTP_ACCEPT_LANGUAGE')) { + $header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE')); + } else { + $header = array(); + } $html = getSimpleHTMLDOM($this->getURI(), $header) or returnServerError('No results for this query.');