You are here

function xmlsitemap_file_transfer in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap.pages.inc \xmlsitemap_file_transfer()

Modified version of file_transfer() that invokes hook_exit()s afterwards.

See also

file_transfer()

1 call to xmlsitemap_file_transfer()
xmlsitemap_output_file in ./xmlsitemap.pages.inc
Output the contents of a file to the browser and check caching headers.

File

./xmlsitemap.pages.inc, line 101
Page callbacks for the xmlsitemap module.

Code

function xmlsitemap_file_transfer($source, $headers) {
  if (ob_get_level()) {
    ob_end_clean();
  }
  foreach ($headers as $header) {
    drupal_set_header($header);
  }

  // Attempt to increase time to transfer file.
  xmlsitemap_set_time_limit(240);

  // Transfer file in 16 KB chunks to save memory usage.
  if ($handle = fopen($source, 'rb')) {
    while (!feof($handle)) {
      print fread($handle, 1024 * 16);
    }
    fclose($handle);
  }
  else {
    drupal_not_found();
  }
  module_invoke_all('exit');
  exit;
}