Bug 683258 - Size reported as -1 bytes when attempting download with no Content-Length header; r=dolske
authorKailas <patilkr24@gmail.com>
Tue, 06 Sep 2011 15:32:52 -0400
changeset 76617 5ab4ecc3ff2ca24d4f02a987964c9e4acdf97653
parent 76616 0392944114b57482f9de08e47a9898c8ebae53d9
child 76618 0874dee6bf422805bc159d54063c535a4db9cd9c
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdolske
bugs683258
milestone9.0a1
Bug 683258 - Size reported as -1 bytes when attempting download with no Content-Length header; r=dolske
toolkit/mozapps/downloads/nsHelperAppDlg.js
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -606,17 +606,18 @@ nsUnknownContentTypeDialog.prototype = {
       catch (ex) {
       }
       if (primaryExtension != "")
         typeString = this.dialogElement("strings").getFormattedString("fileType", [primaryExtension.toUpperCase()]);
       // 3. If we can't even do that, just give up and show the MIME type.
       else
         typeString = mimeInfo.MIMEType;
     }
-    if (this.mLauncher.contentLength) {
+    // When the length is unknown, contentLength would be -1
+    if (this.mLauncher.contentLength >= 0) {
       let [size, unit] = DownloadUtils.
                          convertByteUnits(this.mLauncher.contentLength);
       type.value = this.dialogElement("strings")
                        .getFormattedString("fileSizeWithType", 
                                            [typeString, size, unit]);
     }
     else {
       type.value = typeString;