function backup_file::transfer

cis7 files.inc backup_file::transfer()
cle7 files.inc backup_file::transfer()
elmsmedia7 files.inc backup_file::transfer()
icor7 files.inc backup_file::transfer()
meedjum_blog7 files.inc backup_file::transfer()
mooc7 files.inc backup_file::transfer()

Transfer file using http to client. Similar to the built in file_transfer, but it calls module_invoke_all('exit') so that temp files can be deleted.

File

sites/all/modules/ulmus/backup_migrate/includes/files.inc, line 318
General file handling code for Backup and Migrate.

Class

backup_file
A backup file which allows for saving to and reading from the server.

Code

function transfer() {
  $headers = array(
    array(
      'key' => 'Content-Type',
      'value' => $this->mimetype(),
    ),
    array(
      'key' => 'Content-Disposition',
      'value' => 'attachment; filename="' . $this->filename() . '"',
    ),
  );
  // In some circumstances, web-servers will double compress gzipped files.
  // This may help aleviate that issue by disabling mod-deflate.
  if ($this->mimetype() == 'application/x-gzip') {
    $headers[] = 'Content-Encoding: gzip';
  }
  if ($size = $this->info('filesize')) {
    $headers[] = array(
      'key' => 'Content-Length',
      'value' => $size,
    );
  }

  // Suppress the warning you get when the buffer is empty.
  @ob_end_clean();

  if ($this->open(FALSE, TRUE)) {
    foreach ($headers as $header) {
      // To prevent HTTP header injection, we delete new lines that are
      // not followed by a space or a tab.
      // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
      $header['value'] = preg_replace('/\r?\n(?!\t| )/', '', $header['value']);
      drupal_add_http_header($header['key'], $header['value']);
    }
    // Transfer file in 1024 byte chunks to save memory usage.
    while ($data = $this->read(1024)) {
      print $data;
    }
    $this->close();

    // Ask devel.module not to print it's footer.
    $GLOBALS['devel_shutdown'] = FALSE;
  }
  else {
    drupal_not_found();
  }

  // Start buffering and throw away the results so that errors don't get appended to the file.
  ob_start('_backup_migrate_file_dispose_buffer');
  backup_migrate_cleanup();
  module_invoke_all('exit');
  exit();
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.