Title: [90010] trunk
Revision
90010
Author
[email protected]
Date
2011-06-29 05:43:45 -0700 (Wed, 29 Jun 2011)

Log Message

2011-06-29  Mike West  <[email protected]>

        Reviewed by Pavel Feldman.

        Web Inspector: Missing fields in HAR
        https://bugs.webkit.org/show_bug.cgi?id=58127

        Setting correct expectations for the following fields newly added to
        the HAR implementation:

        - entry.request.httpVersion
        - entry.request.headersSize
        - entry.request.bodySize
        - entry.response.httpVersion
        - entry.response.headersSize
        - entry.response.bodySize
        - entry.response.content.compression

        * http/tests/inspector/network/network-size.html:
        * http/tests/inspector/resource-har-conversion-expected.txt:
        * http/tests/inspector/resource-har-conversion.html:
        * http/tests/inspector/resource-har-headers-expected.txt: Added.
        * http/tests/inspector/resource-har-headers.html: Added.
        * http/tests/inspector/resource-parameters-expected.txt:
        * http/tests/inspector/resources-test.js:
2011-06-29  Mike West  <[email protected]>

        Reviewed by Pavel Feldman.

        Web Inspector: Missing fields in HAR
        https://bugs.webkit.org/show_bug.cgi?id=58127

        Specifically, this patch adds:
        - entry.request.httpVersion
        - entry.request.headersSize
        - entry.request.bodySize
        - entry.response.httpVersion
        - entry.response.headersSize
        - entry.response.bodySize
        - entry.response.content.compression

        Tests: http/tests/inspector/resource-har-conversion.html
               http/tests/inspector/resource-har-headers.html
               http/tests/inspector/resource-parameters.html
               http/tests/inspector/network/network-size.html

        * inspector/front-end/HAREntry.js:
        (WebInspector.HAREntry.prototype.build):
        (WebInspector.HAREntry.prototype._buildRequest):
        (WebInspector.HAREntry.prototype._buildResponse):
        (WebInspector.HAREntry.prototype._buildContent):
        (WebInspector.HAREntry.prototype._buildCookie):
        (WebInspector.HAREntry.prototype._interval):
        (WebInspector.HAREntry.prototype.get requestBodySize):
        (WebInspector.HAREntry.prototype.get responseBodySize):
        (WebInspector.HAREntry.prototype.get responseCompression):
        (WebInspector.HARLog.prototype.build):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype.set requestHeaders):
        (WebInspector.Resource.prototype.get requestHeadersText):
        (WebInspector.Resource.prototype.set requestHeadersText):
        (WebInspector.Resource.prototype.get requestHeadersSize):
        (WebInspector.Resource.prototype.get requestHttpVersion):
        (WebInspector.Resource.prototype.set responseHeaders):
        (WebInspector.Resource.prototype.get responseHeadersText):
        (WebInspector.Resource.prototype.set responseHeadersText):
        (WebInspector.Resource.prototype.get responseHeadersSize):
        (WebInspector.Resource.prototype.get responseHttpVersion):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90009 => 90010)


--- trunk/LayoutTests/ChangeLog	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/ChangeLog	2011-06-29 12:43:45 UTC (rev 90010)
@@ -1,3 +1,29 @@
+2011-06-29  Mike West  <[email protected]>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Missing fields in HAR
+        https://bugs.webkit.org/show_bug.cgi?id=58127
+
+        Setting correct expectations for the following fields newly added to
+        the HAR implementation:
+
+        - entry.request.httpVersion
+        - entry.request.headersSize
+        - entry.request.bodySize
+        - entry.response.httpVersion
+        - entry.response.headersSize
+        - entry.response.bodySize
+        - entry.response.content.compression
+
+        * http/tests/inspector/network/network-size.html:
+        * http/tests/inspector/resource-har-conversion-expected.txt:
+        * http/tests/inspector/resource-har-conversion.html:
+        * http/tests/inspector/resource-har-headers-expected.txt: Added.
+        * http/tests/inspector/resource-har-headers.html: Added.
+        * http/tests/inspector/resource-parameters-expected.txt:
+        * http/tests/inspector/resources-test.js:
+
 2011-06-29  Philippe Normand  <[email protected]>
 
         Unreviewed, skip 2 acid tests on GTK due to bug 54119. They were

Modified: trunk/LayoutTests/http/tests/inspector/network/network-size.html (90009 => 90010)


--- trunk/LayoutTests/http/tests/inspector/network/network-size.html	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/http/tests/inspector/network/network-size.html	2011-06-29 12:43:45 UTC (rev 90010)
@@ -36,12 +36,12 @@
         var resource1 = WebInspector.panels.network.resources[resourcesCount - 2];
         InspectorTest.addResult(resource1.url);
         InspectorTest.addResult("resourceSize: " + resource1.resourceSize);
-        InspectorTest.addResult("transferSize: " + (resource1.transferSize - resource1._responseHeadersSize));
+        InspectorTest.addResult("transferSize: " + (resource1.transferSize - resource1.responseHeadersSize));
 
         var resource2 = WebInspector.panels.network.resources[resourcesCount - 1];
         InspectorTest.addResult(resource2.url);
         InspectorTest.addResult("resourceSize: " + resource2.resourceSize);
-        InspectorTest.addResult("transferSize: " + (resource2.transferSize - resource2._responseHeadersSize));
+        InspectorTest.addResult("transferSize: " + (resource2.transferSize - resource2.responseHeadersSize));
 
         InspectorTest.completeTest();
     }

Modified: trunk/LayoutTests/http/tests/inspector/resource-har-conversion-expected.txt (90009 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resource-har-conversion-expected.txt	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/http/tests/inspector/resource-har-conversion-expected.txt	2011-06-29 12:43:45 UTC (rev 90010)
@@ -26,6 +26,7 @@
             request : {
                 method : "GET"
                 url : "http://127.0.0.1:8000/inspector/inspector-test.js"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 queryString : [
                 ]
@@ -58,12 +59,13 @@
                         secure : false
                     }
                 ]
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             response : {
                 status : 304
                 statusText : "Not Modified"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 cookies : [
                     {
@@ -96,10 +98,11 @@
                 ]
                 content : {
                     size : <number>
+                    compression : <number>
                     mimeType : "application/x-_javascript_"
                 }
                 redirectURL : ""
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             cache : {
@@ -113,26 +116,29 @@
             request : {
                 method : "GET"
                 url : "http://127.0.0.1:8000/inspector/resource-har-conversion.html"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 queryString : [
                 ]
                 cookies : [
                 ]
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             response : {
                 status : 200
                 statusText : "OK"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 cookies : [
                 ]
                 content : {
                     size : <number>
+                    compression : <number>
                     mimeType : "text/html"
                 }
                 redirectURL : ""
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             cache : {
@@ -146,26 +152,29 @@
             request : {
                 method : "GET"
                 url : "http://127.0.0.1:8000/inspector/resources-test.js"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 queryString : [
                 ]
                 cookies : [
                 ]
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             response : {
                 status : 304
                 statusText : "Not Modified"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 cookies : [
                 ]
                 content : {
                     size : <number>
+                    compression : <number>
                     mimeType : "application/x-_javascript_"
                 }
                 redirectURL : ""
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             cache : {
@@ -179,12 +188,13 @@
             request : {
                 method : "POST"
                 url : "http://127.0.0.1:8000/inspector/resources/post-target.cgi"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 queryString : [
                 ]
                 cookies : [
                 ]
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
                 postData : {
                     mimeType : "text/xml"
@@ -194,15 +204,17 @@
             response : {
                 status : 200
                 statusText : "OK"
+                httpVersion : "HTTP/1.1"
                 headers : <object>
                 cookies : [
                 ]
                 content : {
                     size : <number>
+                    compression : <number>
                     mimeType : "application/xml"
                 }
                 redirectURL : ""
-                headersSize : -1
+                headersSize : <number>
                 bodySize : <number>
             }
             cache : {

Modified: trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html (90009 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html	2011-06-29 12:43:45 UTC (rev 90010)
@@ -1,3 +1,4 @@
+<!doctype html>
 <html>
 <head>
 <script src=""
@@ -37,6 +38,7 @@
             resource.requestHeaders = {
                 "Cookie": "a=b; $Path=/path; $Domain=example.com; a1=b1\nc1=d1"
             };
+
             resource.responseHeaders = {
                 "Set-Cookie": "x=y; Path=/path; Domain=example.com; Discard; httpOnly; Secure; Version=1\nx1=y1\nz2=y2"
             };

Added: trunk/LayoutTests/http/tests/inspector/resource-har-headers-expected.txt (0 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resource-har-headers-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-har-headers-expected.txt	2011-06-29 12:43:45 UTC (rev 90010)
@@ -0,0 +1,67 @@
+Tests the nondeterministic bits of HAR conversion via the magic of hard-coded values.
+
+Resource:{
+    request : {
+        headers : {
+            Request : "request-value"
+        }
+        headersText : "GET http://example.com/inspector-test.js HTTP/1.1\r\nRequest: headers-text"
+        headersSize : 72
+    }
+    response : {
+        headers : {
+            Response : "response-value"
+        }
+        headersText : "HTTP/1.1 200 OK\r\nResponse: headers-text"
+        headersSize : 39
+        resourceSize : 1000
+        transferSize : 539
+    }
+}
+HAR:{
+    pageref : "http://example.com/inspector-test.js"
+    startedDateTime : <object>
+    time : <number>
+    request : {
+        method : "GET"
+        url : "http://example.com/inspector-test.js"
+        httpVersion : "HTTP/1.1"
+        headers : [
+            {
+                name : "Request"
+                value : "request-value"
+            }
+        ]
+        queryString : [
+        ]
+        cookies : [
+        ]
+        headersSize : 72
+        bodySize : 0
+    }
+    response : {
+        status : 200
+        statusText : "OK"
+        httpVersion : "HTTP/1.1"
+        headers : [
+            {
+                name : "Response"
+                value : "response-value"
+            }
+        ]
+        cookies : [
+        ]
+        content : {
+            size : 1000
+            compression : 500
+            mimeType : "text/html"
+        }
+        redirectURL : ""
+        headersSize : 39
+        bodySize : 500
+    }
+    cache : {
+    }
+    timings : <object>
+}
+
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-har-headers-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/http/tests/inspector/resource-har-headers.html (0 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resource-har-headers.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resource-har-headers.html	2011-06-29 12:43:45 UTC (rev 90010)
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script>
+var test = function()
+{
+    function visibleNewlines(s)
+    {
+        return s.replace(/\r/, "\\r").replace(/\n/, "\\n");
+    }
+
+    function setResourceValues(resource)
+    {
+        resource.requestHeaders = {
+            "Request": "request-value"
+        };
+        resource.requestHeadersText = "GET http://example.com/inspector-test.js HTTP/1.1\r\nRequest: headers-text";
+
+        resource.responseHeaders = {
+            "Response": "response-value"
+        };
+        resource.responseHeadersText = "HTTP/1.1 200 OK\r\nResponse: headers-text";
+
+        resource.documentURL = "http://example.com/inspector-test.js";
+        resource.requestMethod = "GET";
+        resource.mimeType = "text/html";
+        resource.statusCode = 200;
+        resource.statusText = "OK";
+        resource.resourceSize = 1000;
+        resource._transferSize = 539; // 39 = header size at the end of the day
+    }
+
+    var testResource = new WebInspector.Resource("testResource", "http://example.com/inspector-test.js", 1); 
+    setResourceValues(testResource);
+    var resourceResults = {
+        "request": {
+            "headers": testResource.requestHeaders,
+            "headersText": visibleNewlines(testResource.requestHeadersText),
+            "headersSize": testResource.requestHeadersSize,
+        },
+        "response": {
+            "headers": testResource.responseHeaders,
+            "headersText": visibleNewlines(testResource.responseHeadersText),
+            "headersSize": testResource.responseHeadersSize,
+            "resourceSize": testResource.resourceSize,
+            "transferSize": testResource.transferSize
+        }
+    };
+    InspectorTest.addObject(resourceResults, {}, "", "Resource:");
+
+    var stillNondeterministic = {
+        "startedDateTime": 1,
+        "time": 1,
+        "timings": 1
+    };
+    InspectorTest.addObject(new WebInspector.HAREntry(testResource).build(), stillNondeterministic, "", "HAR:");
+    InspectorTest.completeTest();
+}
+</script>
+
+
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests the nondeterministic bits of HAR conversion via the magic of hard-coded values.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/resource-har-headers.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/http/tests/inspector/resource-parameters-expected.txt (90009 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resource-parameters-expected.txt	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/http/tests/inspector/resource-parameters-expected.txt	2011-06-29 12:43:45 UTC (rev 90010)
@@ -9,6 +9,7 @@
     request : {
         method : "POST"
         url : "http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2="
+        httpVersion : "HTTP/1.1"
         headers : <object>
         queryString : [
             {
@@ -22,8 +23,8 @@
         ]
         cookies : [
         ]
-        headersSize : -1
-        bodySize : -1
+        headersSize : <number>
+        bodySize : <number>
         postData : {
             mimeType : "application/x-www-form-urlencoded"
             text : "formParam1=formValue1&formParam2="
@@ -42,16 +43,18 @@
     response : {
         status : 200
         statusText : "OK"
+        httpVersion : "HTTP/1.1"
         headers : <object>
         cookies : [
         ]
         content : {
             size : 14
+            compression : <number>
             mimeType : "application/xml"
         }
         redirectURL : ""
-        headersSize : -1
-        bodySize : 14
+        headersSize : <number>
+        bodySize : <number>
     }
     cache : {
     }

Modified: trunk/LayoutTests/http/tests/inspector/resources-test.js (90009 => 90010)


--- trunk/LayoutTests/http/tests/inspector/resources-test.js	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/LayoutTests/http/tests/inspector/resources-test.js	2011-06-29 12:43:45 UTC (rev 90010)
@@ -1,25 +1,27 @@
 var initialize_ResourceTest = function() {
 
 InspectorTest.HARNondeterministicProperties = {
+    bodySize: 1,
+    compression: 1,
+    headers: 1,
+    headersSize: 1,
+    id: 1,
+    onContentLoad: 1,
+    onLoad: 1,
+    receive: 1,
     startedDateTime: 1,
     time: 1,
-    wait: 1,
-    receive: 1,
-    headers: 1,
     timings: 1,
     version: 1,
-    startedDateTime: 1,
-    id: 1,
-    onContentLoad: 1,
-    onLoad: 1
+    wait: 1,
 };
 
 // addObject checks own properties only, so make a deep copy rather than use prototype.
 
 InspectorTest.HARNondeterministicPropertiesWithSize = JSON.parse(JSON.stringify(InspectorTest.HARNondeterministicProperties));
 InspectorTest.HARNondeterministicPropertiesWithSize.size = 1;
-InspectorTest.HARNondeterministicPropertiesWithSize.bodySize = 1;
 
+
 InspectorTest.resourceURLComparer = function(r1, r2)
 {
     return r1.request.url.localeCompare(r2.request.url);

Modified: trunk/Source/WebCore/ChangeLog (90009 => 90010)


--- trunk/Source/WebCore/ChangeLog	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/Source/WebCore/ChangeLog	2011-06-29 12:43:45 UTC (rev 90010)
@@ -1,3 +1,47 @@
+2011-06-29  Mike West  <[email protected]>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Missing fields in HAR
+        https://bugs.webkit.org/show_bug.cgi?id=58127
+        
+        Specifically, this patch adds:
+        - entry.request.httpVersion
+        - entry.request.headersSize
+        - entry.request.bodySize
+        - entry.response.httpVersion
+        - entry.response.headersSize
+        - entry.response.bodySize
+        - entry.response.content.compression
+        
+        Tests: http/tests/inspector/resource-har-conversion.html
+               http/tests/inspector/resource-har-headers.html
+               http/tests/inspector/resource-parameters.html
+               http/tests/inspector/network/network-size.html
+
+        * inspector/front-end/HAREntry.js:
+        (WebInspector.HAREntry.prototype.build):
+        (WebInspector.HAREntry.prototype._buildRequest):
+        (WebInspector.HAREntry.prototype._buildResponse):
+        (WebInspector.HAREntry.prototype._buildContent):
+        (WebInspector.HAREntry.prototype._buildCookie):
+        (WebInspector.HAREntry.prototype._interval):
+        (WebInspector.HAREntry.prototype.get requestBodySize):
+        (WebInspector.HAREntry.prototype.get responseBodySize):
+        (WebInspector.HAREntry.prototype.get responseCompression):
+        (WebInspector.HARLog.prototype.build):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.set requestHeaders):
+        (WebInspector.Resource.prototype.get requestHeadersText):
+        (WebInspector.Resource.prototype.set requestHeadersText):
+        (WebInspector.Resource.prototype.get requestHeadersSize):
+        (WebInspector.Resource.prototype.get requestHttpVersion):
+        (WebInspector.Resource.prototype.set responseHeaders):
+        (WebInspector.Resource.prototype.get responseHeadersText):
+        (WebInspector.Resource.prototype.set responseHeadersText):
+        (WebInspector.Resource.prototype.get responseHeadersSize):
+        (WebInspector.Resource.prototype.get responseHttpVersion):
+
 2011-06-29  Hayato Ito  <[email protected]>
 
         Reviewed by Hajime Morita.

Modified: trunk/Source/WebCore/inspector/front-end/HAREntry.js (90009 => 90010)


--- trunk/Source/WebCore/inspector/front-end/HAREntry.js	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/Source/WebCore/inspector/front-end/HAREntry.js	2011-06-29 12:43:45 UTC (rev 90010)
@@ -48,7 +48,7 @@
             time: WebInspector.HAREntry._toMilliseconds(this._resource.duration),
             request: this._buildRequest(),
             response: this._buildResponse(),
-            cache: { }, // Not supproted yet.
+            cache: { }, // Not supported yet.
             timings: this._buildTimings()
         };
     },
@@ -58,15 +58,16 @@
         var res = {
             method: this._resource.requestMethod,
             url: this._buildRequestURL(this._resource.url),
-            // httpVersion: "HTTP/1.1" -- Not available.
+            httpVersion: this._resource.requestHttpVersion,
             headers: this._buildHeaders(this._resource.requestHeaders),
             queryString: this._buildParameters(this._resource.queryParameters || []),
             cookies: this._buildCookies(this._resource.requestCookies || []),
-            headersSize: -1, // Not available.
-            bodySize: -1 // Not available.
+            headersSize: this._resource.requestHeadersSize,
+            bodySize: this.requestBodySize
         };
         if (this._resource.requestFormData)
             res.postData = this._buildPostData();
+
         return res;
     },
 
@@ -75,13 +76,13 @@
         return {
             status: this._resource.statusCode,
             statusText: this._resource.statusText,
-            // "httpVersion": "HTTP/1.1" -- Not available.
+            httpVersion: this._resource.responseHttpVersion,
             headers: this._buildHeaders(this._resource.responseHeaders),
             cookies: this._buildCookies(this._resource.responseCookies || []),
             content: this._buildContent(),
             redirectURL: this._resource.responseHeaderValue("Location") || "",
-            headersSize: -1, // Not available.
-            bodySize: this._resource.resourceSize
+            headersSize: this._resource.responseHeadersSize,
+            bodySize: this.responseBodySize
         };
     },
 
@@ -89,9 +90,9 @@
     {
         return {
             size: this._resource.resourceSize,
-            // compression: 0, -- Not available.
+            compression: this.responseCompression,
             mimeType: this._resource.mimeType,
-            // text: -- Not available.
+            // text: this._resource.content // TODO: pull out into a boolean flag, as content can be huge (and needs to be requested with an async call)
         };
     },
 
@@ -164,7 +165,6 @@
 
     _buildCookie: function(cookie)
     {
-        
         return {
             name: cookie.name,
             value: cookie.value,
@@ -183,6 +183,21 @@
             return -1;
         var startTime = timing[start];
         return typeof startTime !== "number" || startTime === -1 ? -1 : Math.round(timing[end] - startTime);
+    },
+
+    get requestBodySize()
+    {
+        return !this._resource.requestFormData ? 0 : this._resource.requestFormData.length;
+    },
+
+    get responseBodySize()
+    {
+        return this._resource.transferSize - this._resource.responseHeadersSize
+    },
+
+    get responseCompression()
+    {
+        return this._resource.resourceSize - (this._resource.transferSize - this._resource.responseHeadersSize);
     }
 }
 
@@ -199,7 +214,7 @@
     build: function()
     {
         var webKitVersion = /AppleWebKit\/([^ ]+)/.exec(window.navigator.userAgent);
-        
+
         return {
             version: "1.2",
             creator: {

Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (90009 => 90010)


--- trunk/Source/WebCore/inspector/front-end/Resource.js	2011-06-29 11:44:04 UTC (rev 90009)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js	2011-06-29 12:43:45 UTC (rev 90010)
@@ -6,13 +6,13 @@
  * are met:
  *
  * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
+ *     notice, this list of conditions and the following disclaimer.
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
+ *     documentation and/or other materials provided with the distribution.
  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
+ *     from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -492,39 +492,30 @@
         this._requestHeaders = x;
         delete this._sortedRequestHeaders;
         delete this._requestCookies;
-        delete this._responseHeadersSize;
 
         this.dispatchEventToListeners("requestHeaders changed");
     },
 
     get requestHeadersText()
     {
-        if (this._requestHeadersText !== undefined)
-            return this._requestHeadersText;
-
-        this._requestHeadersText = "";
-        for (var key in this.requestHeaders)
-            this._requestHeadersText += key + ": " + this.requestHeaders[key] + "\n"; 
+        if (this._requestHeadersText === undefined) {
+            this._requestHeadersText = this.requestMethod + " " + this.url + " HTTP/1.1\r\n";
+            for (var key in this.requestHeaders)
+                this._requestHeadersText += key + ": " + this.requestHeaders[key] + "\r\n";
+        }
         return this._requestHeadersText;
     },
 
     set requestHeadersText(x)
     {
         this._requestHeadersText = x;
-        delete this._responseHeadersSize;
 
         this.dispatchEventToListeners("requestHeaders changed");
     },
 
     get requestHeadersSize()
     {
-        if (typeof(this._requestHeadersSize) === "undefined") {
-            if (this._requestHeadersText)
-                this._requestHeadersSize = this._requestHeadersText.length;
-            else 
-                this._requestHeadersSize = this._headersSize(this._requestHeaders)
-        }
-        return this._requestHeadersSize;
+        return this.requestHeadersText.length;
     },
 
     get sortedRequestHeaders()
@@ -563,6 +554,13 @@
         delete this._parsedFormParameters;
     },
 
+    get requestHttpVersion()
+    {
+        var firstLine = this.requestHeadersText.split(/\r\n/)[0];
+        var match = firstLine.match(/(HTTP\/\d+\.\d+)$/);
+        return match ? match[1] : undefined;
+    },
+
     get responseHeaders()
     {
         return this._responseHeaders || {};
@@ -571,43 +569,33 @@
     set responseHeaders(x)
     {
         this._responseHeaders = x;
-        delete this._responseHeadersSize;
         delete this._sortedResponseHeaders;
         delete this._responseCookies;
 
         this.dispatchEventToListeners("responseHeaders changed");
     },
-    
+
     get responseHeadersText()
     {
-        if (this._responseHeadersText !== undefined)
-            return this._responseHeadersText;
-        
-        this._responseHeadersText = "";
-        for (var key in this.responseHeaders)
-            this._responseHeadersText += key + ": " + this.responseHeaders[key] + "\n"; 
+        if (this._responseHeadersText === undefined) {
+            this._responseHeadersText = "HTTP/1.1 " + this.statusCode + " " + this.statusText + "\r\n";
+            for (var key in this.responseHeaders)
+                this._responseHeadersText += key + ": " + this.responseHeaders[key] + "\r\n";
+        }
         return this._responseHeadersText;
     },
 
     set responseHeadersText(x)
     {
         this._responseHeadersText = x;
-        delete this._responseHeadersSize;
 
         this.dispatchEventToListeners("responseHeaders changed");
     },
-    
+
     get responseHeadersSize()
     {
-        if (typeof(this._responseHeadersSize) === "undefined") {
-            if (this._responseHeadersText)
-                this._responseHeadersSize = this._responseHeadersText.length;
-            else 
-                this._responseHeadersSize = this._headersSize(this._responseHeaders)
-        }
-        return this._responseHeadersSize;
+        return this.responseHeadersText.length;
     },
-    
 
     get sortedResponseHeaders()
     {
@@ -659,6 +647,12 @@
         return this._parsedFormParameters;
     },
 
+    get responseHttpVersion()
+    {
+        var match = this.responseHeadersText.match(/^(HTTP\/\d+\.\d+)/);
+        return match ? match[1] : undefined;
+    },
+
     _parseParameters: function(queryString)
     {
         function parseNameValue(pair)
@@ -685,16 +679,6 @@
         }
     },
 
-    _headersSize: function(headers)
-    {
-        // We should take actual headers size from network stack, when possible, but fall back to
-        // this lousy computation when no headers text is available.
-        var size = 0;
-        for (var header in headers)
-            size += header.length + headers[header].length + 4; // _typical_ overhead per header is ": ".length + "\r\n".length.
-        return size;
-    },
-
     get messages()
     {
         return this._messages || [];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to