aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-01-24 11:50:18 +0100
committerGravatar GitHub <noreply@github.com> 2024-01-24 11:50:18 +0100
commitc0812032dd8bc12801874c15dbcd59e535ad52b1 (patch)
tree55945d42f3474642467d5a80c014c82f1372d481
parentc66382cc916d3fe79db9ac22a2d6ec3a3c9f921c (diff)
SimplePie log HTTP status of requests (#6061)
To make debugging of e.g. https://github.com/FreshRSS/FreshRSS/issues/6056 easier
-rw-r--r--lib/SimplePie/SimplePie/File.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.php
index 4f6dfe5ed..1c1c585b9 100644
--- a/lib/SimplePie/SimplePie/File.php
+++ b/lib/SimplePie/SimplePie/File.php
@@ -78,10 +78,6 @@ class SimplePie_File
$this->useragent = $useragent;
if (preg_match('/^http(s)?:\/\//i', $url))
{
- if ($syslog_enabled)
- {
- syslog(LOG_INFO, 'SimplePie GET ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS
- }
if ($useragent === null)
{
$useragent = ini_get('user_agent');
@@ -124,6 +120,10 @@ class SimplePie_File
$this->headers = curl_exec($fp);
}
$this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
+ if ($syslog_enabled)
+ {
+ syslog(LOG_INFO, 'SimplePie GET ' . $this->status_code . ' ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS
+ }
if (curl_errno($fp))
{
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
@@ -228,6 +228,10 @@ class SimplePie_File
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
+ if ($syslog_enabled)
+ {
+ syslog(LOG_INFO, 'SimplePie fsock GET ' . $this->status_code . ' ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS
+ }
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
{
$this->redirects++;
@@ -289,6 +293,10 @@ class SimplePie_File
$this->success = false;
}
fclose($fp);
+ if ($syslog_enabled && $this->status_code === 0)
+ {
+ syslog(LOG_INFO, 'SimplePie fsock GET ' . $this->status_code . ' ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS
+ }
}
}
}