aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-03-26 19:13:23 +0100
committerGravatar GitHub <noreply@github.com> 2021-03-26 19:13:23 +0100
commiteeff1a17b0ae13c32560e9d1b59c6e82965f3e6d (patch)
tree8224f828f2d9ea094f2a8f608c0eb1eef07793b1 /lib
parent49f920e19dff22e8026707d98cf93b556a2703a9 (diff)
Suport standard HTTP 410 Gone (#3561)
When a feed returns an HTTP 410 Gone, mute the corresponding feed, i.e. stop refreshing it. Example of such feed, Les Décodeurs (Libération) https://rss.liberation.fr/rss/100893/
Diffstat (limited to 'lib')
-rw-r--r--lib/SimplePie/SimplePie.php20
-rw-r--r--lib/SimplePie/SimplePie/File.php1
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php
index 6a542e2c5..66171dea3 100644
--- a/lib/SimplePie/SimplePie.php
+++ b/lib/SimplePie/SimplePie.php
@@ -431,6 +431,13 @@ class SimplePie
public $error;
/**
+ * @var int HTTP status code
+ * @see SimplePie::status_code()
+ * @access private
+ */
+ public $status_code;
+
+ /**
* @var object Instance of SimplePie_Sanitize (or other class)
* @see SimplePie::set_sanitize_class()
* @access private
@@ -1677,6 +1684,7 @@ class SimplePie
}
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options, $this->syslog_enabled));
+ $this->status_code = $file->status_code;
if ($file->success)
{
@@ -1733,6 +1741,8 @@ class SimplePie
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options, $this->syslog_enabled));
}
}
+ $this->status_code = $file->status_code;
+
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
@@ -1843,6 +1853,16 @@ class SimplePie
}
/**
+ * Get the last HTTP status code
+ *
+ * @return int Status code
+ */
+ public function status_code()
+ {
+ return $this->status_code;
+ }
+
+ /**
* Get the raw XML
*
* This is the same as the old `$feed->enable_xml_dump(true)`, but returns
diff --git a/lib/SimplePie/SimplePie/File.php b/lib/SimplePie/SimplePie/File.php
index 7c7078cc5..0cb3b7861 100644
--- a/lib/SimplePie/SimplePie/File.php
+++ b/lib/SimplePie/SimplePie/File.php
@@ -123,6 +123,7 @@ class SimplePie_File
curl_setopt($fp, CURLOPT_ENCODING, 'none');
$this->headers = curl_exec($fp);
}
+ $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if (curl_errno($fp))
{
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);