From f8530b137bc8d839fb3f4e2dfbb4061b872dc69e Mon Sep 17 00:00:00 2001 From: emc3 Date: Tue, 26 Aug 2003 17:07:36 +0000 Subject: [PATCH] Added support for Conditional GET git-svn-id: http://svn.automattic.com/wordpress/trunk@347 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2rdf.php | 24 ++++++++++++++++++++++++ b2rss.php | 24 ++++++++++++++++++++++++ b2rss2.php | 23 +++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/b2rdf.php b/b2rdf.php index 44654b6c5..7e30cb471 100644 --- a/b2rdf.php +++ b/b2rdf.php @@ -2,6 +2,30 @@ $blog = 1; // enter your blog's ID $doing_rss=1; header('Content-type: text/xml'); + +// Handle Conditional GET + +// Get the time of the most recent article +$sql = "SELECT max(post_date) FROM $tableposts"; + +$maxdate = $wbdp->get_var($sql); + +$unixtime = strtotime($maxdate); + +// format timestamp for Last-Modified header +$last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); + +// send it in a Last-Modified header +header("Last-Modified: $last"); + +// compare it to aggregator's If_Modified_Since +// if they match, send a 304 and die +if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ + header("HTTP/1.1 304 Not Modified"); + exit; +} + + include('blog.header.php'); add_filter('the_content', 'trim'); if (!isset($rss_language)) { $rss_language = 'en'; } diff --git a/b2rss.php b/b2rss.php index 569b9b58a..0b3311531 100644 --- a/b2rss.php +++ b/b2rss.php @@ -3,6 +3,30 @@ $blog = 1; // enter your blog's ID $doing_rss=1; header('Content-type: text/xml'); + +// Handle Conditional GET + +// Get the time of the most recent article +$sql = "SELECT max(post_date) FROM $tableposts"; + +$maxdate = $wbdp->get_var($sql); + +$unixtime = strtotime($maxdate); + +// format timestamp for Last-Modified header +$last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); + +// send it in a Last-Modified header +header("Last-Modified: $last"); + +// compare it to aggregator's If_Modified_Since +// if they match, send a 304 and die +if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ + header("HTTP/1.1 304 Not Modified"); + exit; +} + + include('blog.header.php'); if (!isset($rss_language)) { $rss_language = 'en'; } if (!isset($rss_encoded_html)) { $rss_encoded_html = 0; } diff --git a/b2rss2.php b/b2rss2.php index 7dea088ed..55ff148c7 100644 --- a/b2rss2.php +++ b/b2rss2.php @@ -3,6 +3,29 @@ $blog=1; // enter your blog's ID $doing_rss=1; header('Content-type: text/xml'); + +// Handle Conditional GET + +// Get the time of the most recent article +$sql = "SELECT max(post_date) FROM $tableposts"; + +$maxdate = $wbdp->get_var($sql); + +$unixtime = strtotime($maxdate); + +// format timestamp for Last-Modified header +$last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); + +// send it in a Last-Modified header +header("Last-Modified: $last"); + +// compare it to aggregator's If_Modified_Since +// if they match, send a 304 and die +if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ + header("HTTP/1.1 304 Not Modified"); + exit; +} + include('blog.header.php'); if (!isset($rss_language)) { $rss_language = 'en'; } if (!isset($rss_encoded_html)) { $rss_encoded_html = 0; }