浏览代码

added content-length header as an optional parameter to senddownloadheaders fn

Brian G. Peterson 21 年之前
父节点
当前提交
5b4376af28
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      functions/mime.php

+ 10 - 3
functions/mime.php

@@ -23,7 +23,7 @@ require_once(SM_PATH . 'functions/attachment_common.php');
 
 /**
  * Get the MIME structure
- * 
+ *
  * This function gets the structure of a message and stores it in the "message" class.
  * It will return this object for use with all relevant header information and
  * fully parsed into the standard "message" object format.
@@ -1891,9 +1891,10 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX') {
  * @param string $type1 second half of mime type
  * @param string $filename filename to tell the browser for downloaded file
  * @param boolean $force whether to force the download dialog to pop
+ * @param integer $filesize optional, send the Content-Header and length to the browser
  * @return void
  */
- function SendDownloadHeaders($type0, $type1, $filename, $force) {
+ function SendDownloadHeaders($type0, $type1, $filename, $force, $filesize=0) {
      global $languages, $squirrelmail_language;
      $isIE = $isIE6 = 0;
 
@@ -1954,6 +1955,12 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX') {
              header("Content-Type: application/octet-stream; name=\"$filename\"");
          }
      }
- }
+
+     //send the content-length header if the calling function provides it
+     if ($filesize > 0) {
+        header("Content-Length: $filesize");
+     }
+
+ }  // end fn SendDownlaodHeaders
 
 ?>