cannot download from https using IE

dovry - October 5, 2007 - 10:02
Project:Drupal
Version:5.2
Component:file system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I can not download files from Drupal, server running on https/ssl

  • Using IE7
  • Download method: Private - files are transferred by Drupal.
  • Site accessed over https/ssl

IE can not download the file, apparently because it can not store files downloaded over https in the browser cache.

This issue is described in more detail in a 4.x bug report as well. http://drupal.org/node/163298
I think it is mentioned here as well
http://support.microsoft.com/kb/323308/en-us

The problem can be solved by sending custom headers to IE

#1

dovry - October 5, 2007 - 15:06

I think I've solved the problem by making changes in the file module, similar to the solution others have posted for drupal 4.x (se related bug report).

/**
* Transfer file using http to client. Pipes a file through Drupal to the
* client.
*
* @param $source File to transfer.
* @param $headers An array of http headers to send along with file.
*/
function file_transfer($source, $headers) {
  ob_end_clean();
  global $base_url; //********* added ************
  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 = preg_replace('/\r?\n(?!\t| )/', '', $header);
    drupal_set_header($header);
  }

  //*********** added *******************
  if (preg_match('|^https://|', $base_url)) {
    drupal_set_header('Cache-Control: private');
    drupal_set_header('Pragma: private');
  }
  //*********** /added *******************

  $source = file_create_path($source);

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

 
 

Drupal is a registered trademark of Dries Buytaert.