diff options
Diffstat (limited to 'Source/WebCore/inspector/front-end/Resource.js')
-rw-r--r-- | Source/WebCore/inspector/front-end/Resource.js | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/Source/WebCore/inspector/front-end/Resource.js b/Source/WebCore/inspector/front-end/Resource.js index 00c1fb9..6cf5b9c 100644 --- a/Source/WebCore/inspector/front-end/Resource.js +++ b/Source/WebCore/inspector/front-end/Resource.js @@ -31,9 +31,9 @@ WebInspector.Resource = function(identifier, url) this.url = url; this._startTime = -1; this._endTime = -1; - this._requestMethod = ""; this._category = WebInspector.resourceCategories.other; this._pendingContentCallbacks = []; + this._responseHeadersSize = 0; } // Keep these in sync with WebCore::InspectorResource::Type @@ -237,8 +237,21 @@ WebInspector.Resource.prototype = { get transferSize() { - // FIXME: this is wrong for chunked-encoding resources. - return this.cached ? 0 : Number(this.responseHeaders["Content-Length"] || this.resourceSize || 0); + if (this.cached) + return 0; + if (this.statusCode === 304) // Not modified + return this._responseHeadersSize; + // FIXME: We prefer using Content-Length over resourceSize as + // resourceSize may differ from actual transfer size if platform's + // network stack performed decoding (e.g. gzip decompression). + // The Content-Length, though, is expected to come from raw + // response headers and will reflect actual transfer length. + // This won't work for chunked content encoding, so fall back to + // resourceSize when we don't have Content-Length. This still won't + // work for chunks with non-trivial encodings. We need a way to + // get actaul transfer size from the network stack. + var bodySize = Number(this.responseHeaders["Content-Length"] || this.resourceSize); + return this._responseHeadersSize + bodySize; }, get expectedContentLength() @@ -303,7 +316,6 @@ WebInspector.Resource.prototype = { delete this._timing; }, - get timing() { return this._timing; @@ -431,6 +443,8 @@ WebInspector.Resource.prototype = { set responseHeaders(x) { this._responseHeaders = x; + // FIXME: we should take actual headers size from network stack, when possible. + this._responseHeadersSize = this._headersSize(x); delete this._sortedResponseHeaders; delete this._responseCookies; @@ -512,6 +526,14 @@ WebInspector.Resource.prototype = { } }, + _headersSize: function(headers) + { + var size = 0; + for (var header in headers) + size += header.length + headers[header].length + 3; // _typical_ overhead per herader is ": ".length + "\n".length. + return size; + }, + get errors() { return this._errors || 0; @@ -550,9 +572,9 @@ WebInspector.Resource.prototype = { return true; if (typeof this.type === "undefined" - || this.type === WebInspector.Resource.Type.Other - || this.type === WebInspector.Resource.Type.XHR - || this.type === WebInspector.Resource.Type.WebSocket) + || this.type === WebInspector.Resource.Type.Other + || this.type === WebInspector.Resource.Type.XHR + || this.type === WebInspector.Resource.Type.WebSocket) return true; if (!this.mimeType) @@ -671,8 +693,8 @@ WebInspector.Resource.prototype = { callback(null, null); return; } - if (this._content) { - callback(this._content, this._contentEncoded); + if (typeof this._content !== "undefined") { + callback(this.content, this._contentEncoded); return; } this._pendingContentCallbacks.push(callback); @@ -697,7 +719,7 @@ WebInspector.Resource.prototype = { { const maxDataUrlSize = 1024 * 1024; // If resource content is not available or won't fit a data URL, fall back to using original URL. - if (!this._content || this._content.length > maxDataUrlSize) + if (this._content == null || this._content.length > maxDataUrlSize) return this.url; return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content; @@ -719,7 +741,7 @@ WebInspector.Resource.prototype = { this._pendingContentCallbacks.length = 0; delete this._contentRequested; } - WebInspector.NetworkManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this)); + WebInspector.networkManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this)); } } |