| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
function aggregator_test_menu() {
|
| 8 |
$items['aggregator/test-feed'] = array(
|
| 9 |
'title' => 'Test feed static last modified date',
|
| 10 |
'description' => "A cached test feed with a static last modified date.",
|
| 11 |
'page callback' => 'aggregator_test_feed',
|
| 12 |
'access arguments' => array('access content'),
|
| 13 |
|
| 14 |
return $items;
|
| 15 |
}
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
|
| 26 |
$last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT');
|
| 27 |
$etag = md5($last_modified);
|
| 28 |
|
| 29 |
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
|
| 30 |
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
if ($use_last_modified) {
|
| 35 |
drupal_set_header("Last-Modified: " . gmdate(DATE_RFC1123, $last_modified));
|
| 36 |
}
|
| 37 |
if ($use_etag) {
|
| 38 |
drupal_set_header("ETag: " .$etag);
|
| 39 |
}
|
| 40 |
|
| 41 |
if ($last_modified == $if_modified_since || $etag == $if_none_match) {
|
| 42 |
drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
|
| 43 |
return;
|
| 44 |
}
|
| 45 |
|
| 46 |
|
| 47 |
drupal_set_header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
|
| 48 |
drupal_set_header("Cache-Control: must-revalidate");
|
| 49 |
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
|
| 50 |
|
| 51 |
|
| 52 |
$file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator_test_rss091.xml';
|
| 53 |
$handle = fopen($file_name, 'r');
|
| 54 |
$feed = fread($handle, filesize($file_name));
|
| 55 |
fclose($handle);
|
| 56 |
|
| 57 |
print $feed;
|
| 58 |
}
|
| 59 |
|