WordPress.org

Make WordPress Core

Changeset 348


Ignore:
Timestamp:
08/26/03 19:34:29 (12 years ago)
Author:
emc3
Message:

Added Etag support for Conditional GET, and fixed my horribly broken code from the last commit :)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2rdf.php

    r347 r348  
    33$doing_rss=1; 
    44header('Content-type: text/xml'); 
     5 
     6include('blog.header.php'); 
    57 
    68// Handle Conditional GET 
     
    911$sql = "SELECT max(post_date) FROM $tableposts"; 
    1012 
    11 $maxdate = $wbdp->get_var($sql); 
     13$maxdate = $wpdb->get_var($sql); 
    1214 
    1315$unixtime = strtotime($maxdate); 
    1416 
    1517// format timestamp for Last-Modified header 
    16 $last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     18$clast = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     19$cetag = md5($last); 
     20 
     21$slast = $_SERVER['HTTP_IF_MODIFIED_SINCE']; 
     22$setag = $_SERVER['HTTP_IF_NONE_MATCH']; 
    1723 
    1824// send it in a Last-Modified header 
    19 header("Last-Modified: $last"); 
     25header("Last-Modified: " . $clast); 
     26header("Etag: " . $cetag); 
    2027 
    21 // compare it to aggregator's If_Modified_Since 
     28// compare it to aggregator's If-Modified-Since and If-None-Match headers 
    2229// if they match, send a 304 and die 
    23 if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ 
     30 
     31// This logic says that if only one header is provided, just use that one, 
     32// but if both headers exist, they *both* must match up with the locally 
     33// generated values. 
     34if (($slast?($slast == $clast):true) && ($setag?($setag == $cetag):true)){ 
    2435    header("HTTP/1.1 304 Not Modified"); 
     36    echo "\r\n\r\n"; 
    2537    exit; 
    2638} 
    2739 
    28  
    29 include('blog.header.php'); 
    3040add_filter('the_content', 'trim'); 
    3141if (!isset($rss_language)) { $rss_language = 'en'; } 
  • trunk/b2rss.php

    r347 r348  
    44$doing_rss=1; 
    55header('Content-type: text/xml'); 
     6include('blog.header.php'); 
    67 
    78// Handle Conditional GET 
     
    1011$sql = "SELECT max(post_date) FROM $tableposts"; 
    1112 
    12 $maxdate = $wbdp->get_var($sql); 
     13$maxdate = $wpdb->get_var($sql); 
    1314 
    1415$unixtime = strtotime($maxdate); 
    1516 
    1617// format timestamp for Last-Modified header 
    17 $last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     18$clast = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     19$cetag = md5($last); 
     20 
     21$slast = $_SERVER['HTTP_IF_MODIFIED_SINCE']; 
     22$setag = $_SERVER['HTTP_IF_NONE_MATCH']; 
    1823 
    1924// send it in a Last-Modified header 
    20 header("Last-Modified: $last"); 
     25header("Last-Modified: " . $clast); 
     26header("Etag: " . $cetag); 
    2127 
    22 // compare it to aggregator's If_Modified_Since 
     28// compare it to aggregator's If-Modified-Since and If-None-Match headers 
    2329// if they match, send a 304 and die 
    24 if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ 
     30 
     31// This logic says that if only one header is provided, just use that one, 
     32// but if both headers exist, they *both* must match up with the locally 
     33// generated values. 
     34if (($slast?($slast == $clast):true) && ($setag?($setag == $cetag):true)){ 
    2535    header("HTTP/1.1 304 Not Modified"); 
     36    echo "\r\n\r\n"; 
    2637    exit; 
    2738} 
    2839 
    2940 
    30 include('blog.header.php'); 
    3141if (!isset($rss_language)) { $rss_language = 'en'; } 
    3242if (!isset($rss_encoded_html)) { $rss_encoded_html = 0; } 
  • trunk/b2rss2.php

    r347 r348  
    55header('Content-type: text/xml'); 
    66 
     7include('blog.header.php'); 
     8 
    79// Handle Conditional GET 
    810 
     
    1012$sql = "SELECT max(post_date) FROM $tableposts"; 
    1113 
    12 $maxdate = $wbdp->get_var($sql); 
     14$maxdate = $wpdb->get_var($sql); 
    1315 
    1416$unixtime = strtotime($maxdate); 
    1517 
    1618// format timestamp for Last-Modified header 
    17 $last = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     19$clast = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); 
     20$cetag = md5($last); 
     21 
     22$slast = $_SERVER['HTTP_IF_MODIFIED_SINCE']; 
     23$setag = $_SERVER['HTTP_IF_NONE_MATCH']; 
    1824 
    1925// send it in a Last-Modified header 
    20 header("Last-Modified: $last"); 
     26header("Last-Modified: " . $clast); 
     27header("Etag: " . $cetag); 
    2128 
    22 // compare it to aggregator's If_Modified_Since 
     29// compare it to aggregator's If-Modified-Since and If-None-Match headers 
    2330// if they match, send a 304 and die 
    24 if ($_SERVER[HTTP_IF_MODIFIED_SINCE] == $last){ 
     31 
     32// This logic says that if only one header is provided, just use that one, 
     33// but if both headers exist, they *both* must match up with the locally 
     34// generated values. 
     35if (($slast?($slast == $clast):true) && ($setag?($setag == $cetag):true)){ 
    2536    header("HTTP/1.1 304 Not Modified"); 
     37    echo "\r\n\r\n"; 
    2638    exit; 
    2739} 
    2840 
    29 include('blog.header.php'); 
     41 
    3042if (!isset($rss_language)) { $rss_language = 'en'; } 
    3143if (!isset($rss_encoded_html)) { $rss_encoded_html = 0; } 
Note: See TracChangeset for help on using the changeset viewer.