Bug 1221754 - Set bodySize to 0 in case of 304 responses; r=jryans
authorJan Odvarko <odvarko@gmail.com>
Wed, 11 Nov 2015 14:41:05 +0100
changeset 308693 69777d63651913688cf28161a4636d983e7b4f72
parent 308692 0788d3d500163670f1a01e02cd0c2e11414bfc33
child 308694 b4d21d6aad0ab65e7caca8895619f3d01c12ff67
push id7514
push users.kaspari@gmail.com
push dateFri, 13 Nov 2015 14:12:41 +0000
reviewersjryans
bugs1221754
milestone45.0a1
Bug 1221754 - Set bodySize to 0 in case of 304 responses; r=jryans
devtools/client/netmonitor/har/har-builder.js
--- a/devtools/client/netmonitor/har/har-builder.js
+++ b/devtools/client/netmonitor/har/har-builder.js
@@ -293,17 +293,25 @@ HarBuilder.prototype = {
     response.cookies = this.buildCookies(file.responseCookies);
     response.content = this.buildContent(file);
 
     let headers = responseHeaders ? responseHeaders.headers : null;
     let headersSize = responseHeaders ? responseHeaders.headersSize : -1;
 
     response.redirectURL = findValue(headers, "Location");
     response.headersSize = headersSize;
-    response.bodySize = file.transferredSize || -1;
+
+    // 'bodySize' is size of the received response body in bytes.
+    // Set to zero in case of responses coming from the cache (304).
+    // Set to -1 if the info is not available.
+    if (typeof file.transferredSize != "number") {
+      response.bodySize = (response.status == 304) ? 0 : -1;
+    } else {
+      response.bodySize = file.transferredSize;
+    }
 
     return response;
   },
 
   buildContent: function(file) {
     let content = {
       mimeType: file.mimeType,
       size: -1