From 5ea8116cfd4916b266e9f6d13c428e2a00777fcd Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 2 Sep 2019 20:39:51 +0000 Subject: [PATCH 1/2] Workaround for HTTP error 417 --- src/Util/Network.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Util/Network.php b/src/Util/Network.php index cd66abe0b..633f1cadb 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -284,8 +284,8 @@ class Network $curl_time = Config::get('system', 'curl_timeout', 60); curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time)); } - - if (defined('LIGHTTPD')) { +/* +// if (defined('LIGHTTPD')) { if (empty($headers)) { $headers = ['Expect:']; } else { @@ -293,8 +293,8 @@ class Network array_push($headers, 'Expect:'); } } - } - +// } +*/ if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } @@ -336,6 +336,21 @@ class Network curl_close($ch); $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); +Logger::info('Blubb', ['code' => $curlResponse->getReturnCode()]); + // Some servers don't like the "Expect" header, so we remove it when needed + if ($curlResponse->getReturnCode() == 417) { + $redirects++; + + if (empty($headers)) { + $headers = ['Expect:']; + } else { + if (!in_array('Expect:', $headers)) { + array_push($headers, 'Expect:'); + } + } + Logger::info('Server responds with 417, applying workaround', ['url' => $url]); + return self::post($url, $params, $headers, $redirects, $timeout); + } Logger::log('post_url: end ' . $url, Logger::DATA); From 4664249fec21a07264f81ca6c66840c78a17f8b4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 17 Oct 2019 21:49:29 +0000 Subject: [PATCH 2/2] Improved comment --- src/Util/Network.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Util/Network.php b/src/Util/Network.php index fd1f2855d..f222dc22d 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -284,17 +284,7 @@ class Network $curl_time = Config::get('system', 'curl_timeout', 60); curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time)); } -/* -// if (defined('LIGHTTPD')) { - if (empty($headers)) { - $headers = ['Expect:']; - } else { - if (!in_array('Expect:', $headers)) { - array_push($headers, 'Expect:'); - } - } -// } -*/ + if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } @@ -336,8 +326,8 @@ class Network curl_close($ch); $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack()); -Logger::info('Blubb', ['code' => $curlResponse->getReturnCode()]); - // Some servers don't like the "Expect" header, so we remove it when needed + + // Very old versions of Lighttpd don't like the "Expect" header, so we remove it when needed if ($curlResponse->getReturnCode() == 417) { $redirects++;