Web Inspector: HAR Extension for `serverIPAddress` port number
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 18:47:43 +0000 (18:47 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 18:47:43 +0000 (18:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195695

Reviewed by Matt Baker.

Source/WebInspectorUI:

* UserInterface/Controllers/HARBuilder.js:
(WI.HARBuilder.entry):
(WI.HARBuilder.port):
* UserInterface/Models/LocalResource.js:
(WI.LocalResource.fromHAREntry):

LayoutTests:

* http/tests/inspector/network/har/har-basic-expected.txt:
* http/tests/inspector/network/har/har-page-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243087 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/har/har-basic-expected.txt
LayoutTests/http/tests/inspector/network/har/har-page-expected.txt
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/HARBuilder.js
Source/WebInspectorUI/UserInterface/Models/LocalResource.js

index 7bfd62a..90c7d1c 100644 (file)
@@ -1,5 +1,15 @@
 2019-03-18  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: HAR Extension for `serverIPAddress` port number
+        https://bugs.webkit.org/show_bug.cgi?id=195695
+
+        Reviewed by Matt Baker.
+
+        * http/tests/inspector/network/har/har-basic-expected.txt:
+        * http/tests/inspector/network/har/har-page-expected.txt:
+
+2019-03-18  Joseph Pecoraro  <pecoraro@apple.com>
+
         Unreviewed test gardening after r243024.
 
         * inspector/timeline/timeline-recording-expected.txt:
index 97a10bf..68e8310 100644 (file)
@@ -135,6 +135,7 @@ Basic tests for HAR.
           "receive": 99.99999999999987
         },
         "serverIPAddress": "12.34.56.78",
+        "_serverPort": 443,
         "connection": "1",
         "_fetchType": "Network Load",
         "_priority": "medium"
index 7d5b3b7..d3db1ae 100644 (file)
@@ -62,6 +62,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "high"
       },
       {
@@ -104,6 +105,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "high"
       },
       {
@@ -146,6 +148,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "high"
       },
       {
@@ -195,6 +198,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -250,6 +254,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -304,6 +309,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -358,6 +364,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -412,6 +419,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -470,6 +478,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -534,6 +543,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -602,6 +612,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -674,6 +685,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       },
       {
@@ -750,6 +762,7 @@ HAR Page Test.
           "wait": "<filtered>",
           "receive": "<filtered>"
         },
+        "_serverPort": 8000,
         "_priority": "medium"
       }
     ]
index 43d48ab..1762732 100644 (file)
@@ -1,3 +1,16 @@
+2019-03-18  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: HAR Extension for `serverIPAddress` port number
+        https://bugs.webkit.org/show_bug.cgi?id=195695
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Controllers/HARBuilder.js:
+        (WI.HARBuilder.entry):
+        (WI.HARBuilder.port):
+        * UserInterface/Models/LocalResource.js:
+        (WI.LocalResource.fromHAREntry):
+
 2019-03-16  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Changes: style attribute changes aren't being tracked
index 48e90ce..80c4115 100644 (file)
@@ -105,7 +105,10 @@ WI.HARBuilder = class HARBuilder
             entry.time = (resource.timingData.responseEnd - resource.timingData.startTime) * 1000;
         if (resource.remoteAddress) {
             entry.serverIPAddress = HARBuilder.ipAddress(resource.remoteAddress);
-            // FIXME: <https://webkit.org/b/195695> Web Inspector: HAR Extension for `serverIPAddress` port number
+
+            // WebKit Custom Field `_serverPort`.
+            if (entry.serverIPAddress)
+                entry._serverPort = HARBuilder.port(resource.remoteAddress);
         }
         if (resource.connectionIdentifier)
             entry.connection = "" + resource.connectionIdentifier;
@@ -295,6 +298,26 @@ WI.HARBuilder = class HARBuilder
         return remoteAddress.replace(/:\d+$/, "");
     }
 
+    static port(remoteAddress)
+    {
+        // IP Address, without port.
+        if (!remoteAddress)
+            return undefined;
+
+        // NOTE: Resource.remoteAddress always includes the port at the end.
+        // So this always matches the last part.
+        let index = remoteAddress.lastIndexOf(":");
+        if (!index)
+            return undefined;
+
+        let portString = remoteAddress.substr(index + 1);
+        let port = parseInt(portString);
+        if (isNaN(port))
+            return undefined;
+
+        return port;
+    }
+
     static date(date)
     {
         // ISO 8601
index fb8ab42..fce4198 100644 (file)
@@ -97,7 +97,6 @@ WI.LocalResource = class LocalResource extends WI.Resource
 
     static fromHAREntry(entry, archiveStartWalltime)
     {
-        // FIXME: <https://webkit.org/b/195695> Web Inspector: HAR Extension for `serverIPAddress` port number
         // FIXME: <https://webkit.org/b/195694> Web Inspector: HAR Extension for Redirect Timing Info
 
         let {request, response, startedDateTime, timings} = entry;
@@ -159,6 +158,10 @@ WI.LocalResource = class LocalResource extends WI.Resource
             finishedTimestamp = timing.responseEnd;
         }
 
+        let serverAddress = entry.serverIPAddress || null;
+        if (serverAddress && typeof entry._serverPort === "number")
+            serverAddress += ":" + entry._serverPort;
+
         return new WI.LocalResource({
             request: {
                 url: request.url,
@@ -182,7 +185,7 @@ WI.LocalResource = class LocalResource extends WI.Resource
                 responseSource: WI.HARBuilder.responseSourceFromHARFetchType(entry._fetchType),
                 protocol: WI.HARBuilder.protocolFromHARProtocol(response.httpVersion),
                 priority: WI.HARBuilder.networkPriorityFromHARPriority(entry._priority),
-                remoteAddress: entry.serverIPAddress || null,
+                remoteAddress: serverAddress,
                 connectionIdentifier: entry.connection ? parseInt(entry.connection) : null,
                 requestHeaderBytesSent: request.headersSize >= 0 ? request.headersSize : NaN,
                 requestBodyBytesSent: request.bodySize >= 0 ? request.bodySize : NaN,