You are here

function xmlsitemap_file_transfer in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.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($uri, $headers) {
  if (ob_get_level()) {
    ob_end_clean();
  }
  foreach ($headers as $name => $value) {
    drupal_add_http_header($name, $value);
  }
  drupal_send_headers();

  // Attempt to increase time to transfer file.
  drupal_set_time_limit(240);
  $scheme = variable_get('file_default_scheme', 'public');

  // Transfer file in 16 KB chunks to save memory usage.
  if ($scheme && file_stream_wrapper_valid_scheme($scheme) && ($fd = fopen($uri, 'rb'))) {
    while (!feof($fd)) {
      print fread($fd, 1024 * 16);
    }
    fclose($fd);

    // Disable session manipulation if PHP transferred a file.
    drupal_save_session(FALSE);
  }
  else {
    drupal_not_found();
  }
  drupal_exit();
}