Changeset 87070 in webkit


Ignore:
Timestamp:
May 23, 2011 6:29:25 AM (13 years ago)
Author:
caseq@chromium.org
Message:

2011-05-23 Mike West <mkwst@chromium.org>

Reviewed by Yury Semikhatsky.

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-05-23 Mike West <mkwst@chromium.org>

Reviewed by Yury Semikhatsky.

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

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87069 r87070  
     12011-05-23  Mike West  <mkwst@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Missing fields in HAR
     6        https://bugs.webkit.org/show_bug.cgi?id=58127
     7
     8        Setting correct expectations for the following fields newly added to
     9        the HAR implementation:
     10        - entry.request.httpVersion
     11        - entry.request.headersSize
     12        - entry.request.bodySize
     13        - entry.response.httpVersion
     14        - entry.response.headersSize
     15        - entry.response.bodySize
     16        - entry.response.content.compression
     17
     18        * http/tests/inspector/network/network-size.html:
     19        * http/tests/inspector/resource-har-conversion-expected.txt:
     20        * http/tests/inspector/resource-har-conversion.html:
     21        * http/tests/inspector/resource-har-headers-expected.txt: Added.
     22        * http/tests/inspector/resource-har-headers.html: Added.
     23        * http/tests/inspector/resource-parameters-expected.txt:
     24        * http/tests/inspector/resources-test.js:
     25
    1262011-05-23  Csaba Osztrogonác  <ossy@webkit.org>
    227
  • trunk/LayoutTests/http/tests/inspector/network/network-size.html

    r86672 r87070  
    3737        InspectorTest.addResult(resource1.url);
    3838        InspectorTest.addResult("resourceSize: " + resource1.resourceSize);
    39         InspectorTest.addResult("transferSize: " + (resource1.transferSize - resource1._responseHeadersSize));
     39        InspectorTest.addResult("transferSize: " + (resource1.transferSize - resource1.responseHeadersSize));
    4040
    4141        var resource2 = WebInspector.panels.network.resources[resourcesCount - 1];
    4242        InspectorTest.addResult(resource2.url);
    4343        InspectorTest.addResult("resourceSize: " + resource2.resourceSize);
    44         InspectorTest.addResult("transferSize: " + (resource2.transferSize - resource2._responseHeadersSize));
     44        InspectorTest.addResult("transferSize: " + (resource2.transferSize - resource2.responseHeadersSize));
    4545
    4646        InspectorTest.completeTest();
  • trunk/LayoutTests/http/tests/inspector/resource-har-conversion-expected.txt

    r83583 r87070  
    2727                method : "GET"
    2828                url : "http://127.0.0.1:8000/inspector/inspector-test.js"
     29                httpVersion : "HTTP/1.1"
    2930                headers : <object>
    3031                queryString : [
     
    5960                    }
    6061                ]
    61                 headersSize : -1
     62                headersSize : <number>
    6263                bodySize : <number>
    6364            }
     
    6566                status : 304
    6667                statusText : "Not Modified"
     68                httpVersion : "HTTP/1.1"
    6769                headers : <object>
    6870                cookies : [
     
    9799                content : {
    98100                    size : <number>
     101                    compression : <number>
    99102                    mimeType : "application/x-javascript"
    100103                }
    101104                redirectURL : ""
    102                 headersSize : -1
     105                headersSize : <number>
    103106                bodySize : <number>
    104107            }
     
    114117                method : "GET"
    115118                url : "http://127.0.0.1:8000/inspector/resource-har-conversion.html"
    116                 headers : <object>
    117                 queryString : [
    118                 ]
    119                 cookies : [
    120                 ]
    121                 headersSize : -1
     119                httpVersion : "HTTP/1.1"
     120                headers : <object>
     121                queryString : [
     122                ]
     123                cookies : [
     124                ]
     125                headersSize : <number>
    122126                bodySize : <number>
    123127            }
     
    125129                status : 200
    126130                statusText : "OK"
    127                 headers : <object>
    128                 cookies : [
    129                 ]
    130                 content : {
    131                     size : <number>
     131                httpVersion : "HTTP/1.1"
     132                headers : <object>
     133                cookies : [
     134                ]
     135                content : {
     136                    size : <number>
     137                    compression : <number>
    132138                    mimeType : "text/html"
    133139                }
    134140                redirectURL : ""
    135                 headersSize : -1
     141                headersSize : <number>
    136142                bodySize : <number>
    137143            }
     
    147153                method : "GET"
    148154                url : "http://127.0.0.1:8000/inspector/resources-test.js"
    149                 headers : <object>
    150                 queryString : [
    151                 ]
    152                 cookies : [
    153                 ]
    154                 headersSize : -1
     155                httpVersion : "HTTP/1.1"
     156                headers : <object>
     157                queryString : [
     158                ]
     159                cookies : [
     160                ]
     161                headersSize : <number>
    155162                bodySize : <number>
    156163            }
     
    158165                status : 304
    159166                statusText : "Not Modified"
    160                 headers : <object>
    161                 cookies : [
    162                 ]
    163                 content : {
    164                     size : <number>
     167                httpVersion : "HTTP/1.1"
     168                headers : <object>
     169                cookies : [
     170                ]
     171                content : {
     172                    size : <number>
     173                    compression : <number>
    165174                    mimeType : "application/x-javascript"
    166175                }
    167176                redirectURL : ""
    168                 headersSize : -1
     177                headersSize : <number>
    169178                bodySize : <number>
    170179            }
     
    180189                method : "POST"
    181190                url : "http://127.0.0.1:8000/inspector/resources/post-target.cgi"
    182                 headers : <object>
    183                 queryString : [
    184                 ]
    185                 cookies : [
    186                 ]
    187                 headersSize : -1
     191                httpVersion : "HTTP/1.1"
     192                headers : <object>
     193                queryString : [
     194                ]
     195                cookies : [
     196                ]
     197                headersSize : <number>
    188198                bodySize : <number>
    189199                postData : {
     
    195205                status : 200
    196206                statusText : "OK"
    197                 headers : <object>
    198                 cookies : [
    199                 ]
    200                 content : {
    201                     size : <number>
     207                httpVersion : "HTTP/1.1"
     208                headers : <object>
     209                cookies : [
     210                ]
     211                content : {
     212                    size : <number>
     213                    compression : <number>
    202214                    mimeType : "application/xml"
    203215                }
    204216                redirectURL : ""
    205                 headersSize : -1
     217                headersSize : <number>
    206218                bodySize : <number>
    207219            }
  • trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html

    r83275 r87070  
     1<!doctype html>
    12<html>
    23<head>
     
    3839                "Cookie": "a=b; $Path=/path; $Domain=example.com; a1=b1\nc1=d1"
    3940            };
     41
    4042            resource.responseHeaders = {
    4143                "Set-Cookie": "x=y; Path=/path; Domain=example.com; Discard; httpOnly; Secure; Version=1\nx1=y1\nz2=y2"
  • trunk/LayoutTests/http/tests/inspector/resource-parameters-expected.txt

    r83583 r87070  
    1010        method : "POST"
    1111        url : "http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2="
     12        httpVersion : "HTTP/1.1"
    1213        headers : <object>
    1314        queryString : [
     
    2324        cookies : [
    2425        ]
    25         headersSize : -1
    26         bodySize : -1
     26        headersSize : <number>
     27        bodySize : 33
    2728        postData : {
    2829            mimeType : "application/x-www-form-urlencoded"
     
    4344        status : 200
    4445        statusText : "OK"
     46        httpVersion : "HTTP/1.1"
    4547        headers : <object>
    4648        cookies : [
     
    4850        content : {
    4951            size : 14
     52            compression : 0
    5053            mimeType : "application/xml"
    5154        }
    5255        redirectURL : ""
    53         headersSize : -1
     56        headersSize : <number>
    5457        bodySize : 14
    5558    }
  • trunk/LayoutTests/http/tests/inspector/resources-test.js

    r83275 r87070  
    22
    33InspectorTest.HARNondeterministicProperties = {
     4    headers: 1,
     5    headersSize: 1,
     6    id: 1,
     7    onContentLoad: 1,
     8    onLoad: 1,
     9    receive: 1,
    410    startedDateTime: 1,
    511    time: 1,
    6     wait: 1,
    7     receive: 1,
    8     headers: 1,
    912    timings: 1,
    1013    version: 1,
    11     startedDateTime: 1,
    12     id: 1,
    13     onContentLoad: 1,
    14     onLoad: 1
     14    wait: 1,
    1515};
    1616
     
    2020InspectorTest.HARNondeterministicPropertiesWithSize.size = 1;
    2121InspectorTest.HARNondeterministicPropertiesWithSize.bodySize = 1;
     22InspectorTest.HARNondeterministicPropertiesWithSize.compression = 1;
     23
    2224
    2325InspectorTest.resourceURLComparer = function(r1, r2)
  • trunk/Source/WebCore/ChangeLog

    r87068 r87070  
     12011-05-23  Mike West  <mkwst@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Missing fields in HAR
     6        https://bugs.webkit.org/show_bug.cgi?id=58127
     7       
     8        Specifically, this patch adds:
     9        - entry.request.httpVersion
     10        - entry.request.headersSize
     11        - entry.request.bodySize
     12        - entry.response.httpVersion
     13        - entry.response.headersSize
     14        - entry.response.bodySize
     15        - entry.response.content.compression
     16       
     17        Tests: http/tests/inspector/resource-har-conversion.html
     18               http/tests/inspector/resource-har-headers.html
     19               http/tests/inspector/resource-parameters.html
     20               http/tests/inspector/network/network-size.html
     21
     22        * inspector/front-end/HAREntry.js:
     23        (WebInspector.HAREntry.prototype.build):
     24        (WebInspector.HAREntry.prototype._buildRequest):
     25        (WebInspector.HAREntry.prototype._buildResponse):
     26        (WebInspector.HAREntry.prototype._buildContent):
     27        (WebInspector.HAREntry.prototype._buildCookie):
     28        (WebInspector.HAREntry.prototype._interval):
     29        (WebInspector.HAREntry.prototype.get requestBodySize):
     30        (WebInspector.HAREntry.prototype.get responseBodySize):
     31        (WebInspector.HAREntry.prototype.get responseCompression):
     32        (WebInspector.HARLog.prototype.build):
     33        * inspector/front-end/Resource.js:
     34        (WebInspector.Resource.prototype.set requestHeaders):
     35        (WebInspector.Resource.prototype.get requestHeadersText):
     36        (WebInspector.Resource.prototype.set requestHeadersText):
     37        (WebInspector.Resource.prototype.get requestHeadersSize):
     38        (WebInspector.Resource.prototype.get requestHttpVersion):
     39        (WebInspector.Resource.prototype.set responseHeaders):
     40        (WebInspector.Resource.prototype.get responseHeadersText):
     41        (WebInspector.Resource.prototype.set responseHeadersText):
     42        (WebInspector.Resource.prototype.get responseHeadersSize):
     43        (WebInspector.Resource.prototype.get responseHttpVersion):
     44
    1452011-05-23  Andrey Kosyakov  <caseq@chromium.org>
    246
  • trunk/Source/WebCore/inspector/front-end/HAREntry.js

    r83275 r87070  
    4949            request: this._buildRequest(),
    5050            response: this._buildResponse(),
    51             cache: { }, // Not supproted yet.
     51            cache: { }, // Not supported yet.
    5252            timings: this._buildTimings()
    5353        };
     
    5959            method: this._resource.requestMethod,
    6060            url: this._resource.url,
    61             // httpVersion: "HTTP/1.1" -- Not available.
     61            httpVersion: this._resource.requestHttpVersion,
    6262            headers: this._buildHeaders(this._resource.requestHeaders),
    6363            queryString: this._buildParameters(this._resource.queryParameters || []),
    6464            cookies: this._buildCookies(this._resource.requestCookies || []),
    65             headersSize: -1, // Not available.
    66             bodySize: -1 // Not available.
     65            headersSize: this._resource.requestHeadersSize,
     66            bodySize: this.requestBodySize
    6767        };
    6868        if (this._resource.requestFormData)
    6969            res.postData = this._buildPostData();
     70
    7071        return res;
    7172    },
     
    7677            status: this._resource.statusCode,
    7778            statusText: this._resource.statusText,
    78             // "httpVersion": "HTTP/1.1" -- Not available.
     79            httpVersion: this._resource.responseHttpVersion,
    7980            headers: this._buildHeaders(this._resource.responseHeaders),
    8081            cookies: this._buildCookies(this._resource.responseCookies || []),
    8182            content: this._buildContent(),
    8283            redirectURL: this._resource.responseHeaderValue("Location") || "",
    83             headersSize: -1, // Not available.
    84             bodySize: this._resource.resourceSize
     84            headersSize: this._resource.responseHeadersSize,
     85            bodySize: this.responseBodySize
    8586        };
    8687    },
     
    9091        return {
    9192            size: this._resource.resourceSize,
    92             // compression: 0, -- Not available.
     93            compression: this.responseCompression,
    9394            mimeType: this._resource.mimeType,
    94             // text: -- Not available.
     95            // 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)
    9596        };
    9697    },
     
    160161    _buildCookie: function(cookie)
    161162    {
    162        
    163163        return {
    164164            name: cookie.name,
     
    179179        var startTime = timing[start];
    180180        return typeof startTime !== "number" || startTime === -1 ? -1 : Math.round(timing[end] - startTime);
     181    },
     182
     183    get requestBodySize()
     184    {
     185        return !this._resource.requestFormData ? 0 : this._resource.requestFormData.length;
     186    },
     187
     188    get responseBodySize()
     189    {
     190        return this._resource.transferSize - this._resource.responseHeadersSize
     191    },
     192
     193    get responseCompression()
     194    {
     195        return this._resource.resourceSize - (this._resource.transferSize - this._resource.responseHeadersSize);
    181196    }
    182197}
     
    195210    {
    196211        var webKitVersion = /AppleWebKit\/([^ ]+)/.exec(window.navigator.userAgent);
    197        
     212
    198213        return {
    199214            version: "1.2",
  • trunk/Source/WebCore/inspector/front-end/Resource.js

    r85591 r87070  
    77 *
    88 * 1.  Redistributions of source code must retain the above copyright
    9  *     notice, this list of conditions and the following disclaimer. 
     9 *     notice, this list of conditions and the following disclaimer.
    1010 * 2.  Redistributions in binary form must reproduce the above copyright
    1111 *     notice, this list of conditions and the following disclaimer in the
    12  *     documentation and/or other materials provided with the distribution. 
     12 *     documentation and/or other materials provided with the distribution.
    1313 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
    1414 *     its contributors may be used to endorse or promote products derived
    15  *     from this software without specific prior written permission. 
     15 *     from this software without specific prior written permission.
    1616 *
    1717 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     
    492492        delete this._sortedRequestHeaders;
    493493        delete this._requestCookies;
    494         delete this._responseHeadersSize;
    495494
    496495        this.dispatchEventToListeners("requestHeaders changed");
     
    499498    get requestHeadersText()
    500499    {
    501         if (this._requestHeadersText !== undefined)
    502             return this._requestHeadersText;
    503 
    504         this._requestHeadersText = "";
    505         for (var key in this.requestHeaders)
    506             this._requestHeadersText += key + ": " + this.requestHeaders[key] + "\n";
     500        if (this._requestHeadersText === undefined) {
     501            this._requestHeadersText = this.requestMethod + " " + this.url + " HTTP/1.1\r\n";
     502            for (var key in this.requestHeaders)
     503                this._requestHeadersText += key + ": " + this.requestHeaders[key] + "\r\n";
     504        }
    507505        return this._requestHeadersText;
    508506    },
     
    511509    {
    512510        this._requestHeadersText = x;
    513         delete this._responseHeadersSize;
    514511
    515512        this.dispatchEventToListeners("requestHeaders changed");
     
    518515    get requestHeadersSize()
    519516    {
    520         if (typeof(this._requestHeadersSize) === "undefined") {
    521             if (this._requestHeadersText)
    522                 this._requestHeadersSize = this._requestHeadersText.length;
    523             else
    524                 this._requestHeadersSize = this._headersSize(this._requestHeaders)
    525         }
    526         return this._requestHeadersSize;
     517        return this.requestHeadersText.length;
    527518    },
    528519
     
    563554    },
    564555
     556    get requestHttpVersion()
     557    {
     558        var firstLine = this.requestHeadersText.split(/\r\n/)[0];
     559        var match = firstLine.match(/(HTTP\/\d+\.\d+)$/);
     560        return match ? match[1] : undefined;
     561    },
     562
    565563    get responseHeaders()
    566564    {
     
    571569    {
    572570        this._responseHeaders = x;
    573         delete this._responseHeadersSize;
    574571        delete this._sortedResponseHeaders;
    575572        delete this._responseCookies;
     
    577574        this.dispatchEventToListeners("responseHeaders changed");
    578575    },
    579    
     576
    580577    get responseHeadersText()
    581578    {
    582         if (this._responseHeadersText !== undefined)
    583             return this._responseHeadersText;
    584        
    585         this._responseHeadersText = "";
    586         for (var key in this.responseHeaders)
    587             this._responseHeadersText += key + ": " + this.responseHeaders[key] + "\n";
     579        if (this._responseHeadersText === undefined) {
     580            this._responseHeadersText = "HTTP/1.1 " + this.statusCode + " " + this.statusText + "\r\n";
     581            for (var key in this.responseHeaders)
     582                this._responseHeadersText += key + ": " + this.responseHeaders[key] + "\r\n";
     583        }
    588584        return this._responseHeadersText;
    589585    },
     
    592588    {
    593589        this._responseHeadersText = x;
    594         delete this._responseHeadersSize;
    595590
    596591        this.dispatchEventToListeners("responseHeaders changed");
    597592    },
    598    
     593
    599594    get responseHeadersSize()
    600595    {
    601         if (typeof(this._responseHeadersSize) === "undefined") {
    602             if (this._responseHeadersText)
    603                 this._responseHeadersSize = this._responseHeadersText.length;
    604             else
    605                 this._responseHeadersSize = this._headersSize(this._responseHeaders)
    606         }
    607         return this._responseHeadersSize;
    608     },
    609    
     596        return this.responseHeadersText.length;
     597    },
    610598
    611599    get sortedResponseHeaders()
     
    656644        this._parsedFormParameters = this._parseParameters(this.requestFormData);
    657645        return this._parsedFormParameters;
     646    },
     647
     648    get responseHttpVersion()
     649    {
     650        var match = this.responseHeadersText.match(/^(HTTP\/\d+\.\d+)/);
     651        return match ? match[1] : undefined;
    658652    },
    659653
     
    682676                return headers[header];
    683677        }
    684     },
    685 
    686     _headersSize: function(headers)
    687     {
    688         // We should take actual headers size from network stack, when possible, but fall back to
    689         // this lousy computation when no headers text is available.
    690         var size = 0;
    691         for (var header in headers)
    692             size += header.length + headers[header].length + 4; // _typical_ overhead per header is ": ".length + "\r\n".length.
    693         return size;
    694678    },
    695679
Note: See TracChangeset for help on using the changeset viewer.