[Curl] Fix missing values of resource timing API.
authorBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 20:45:30 +0000 (20:45 +0000)
committerBasuke.Suzuki@sony.com <Basuke.Suzuki@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 20:45:30 +0000 (20:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190193

Reviewed by Alex Christensen.

Source/WebCore:

The property nextHopProtocol was not returned correctly. It was
returned only when remote inspector is opened.

Tests: http/wpt/resource-timing/rt-nextHopProtocol.html
       http/wpt/resource-timing/rt-nextHopProtocol.worker.html

* platform/network/curl/CurlContext.cpp:
(WebCore::CurlHandle::getNetworkLoadMetrics):
(WebCore::CurlHandle::addExtraNetworkLoadMetrics):

LayoutTests:

* platform/wincairo/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/platform/wincairo/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/network/curl/CurlContext.cpp

index 763281f..135de0f 100644 (file)
@@ -1,3 +1,12 @@
+2018-10-02  Basuke Suzuki  <Basuke.Suzuki@sony.com>
+
+        [Curl] Fix missing values of  resource timing API.
+        https://bugs.webkit.org/show_bug.cgi?id=190193
+
+        Reviewed by Alex Christensen.
+
+        * platform/wincairo/TestExpectations:
+
 2018-10-02  Per Arne Vollan  <pvollan@apple.com>
 
         [WebVTT] Cue with line setting is not rendered correctly
index 989f912..93905cb 100644 (file)
@@ -1046,8 +1046,6 @@ http/wpt/resource-timing/rt-initiatorType-other.html [ Failure Pass ]
 http/wpt/resource-timing/rt-initiatorType-script-module.html [ Failure Pass ]
 http/wpt/resource-timing/rt-initiatorType-xmlhttprequest.html [ Failure Pass ]
 http/wpt/resource-timing/rt-initiatorType.worker.html [ Failure Pass ]
-http/wpt/resource-timing/rt-nextHopProtocol.html [ Failure ]
-http/wpt/resource-timing/rt-nextHopProtocol.worker.html [ Failure ]
 http/wpt/resource-timing/rt-revalidate-requests.html [ Failure Pass ]
 http/wpt/resource-timing/rt-shared-resource-in-frames.html [ Failure Pass ]
 http/wpt/resource-timing/rt-shared-resource-in-workers.html [ Failure Pass ]
index d638063..4604f23 100644 (file)
@@ -1,3 +1,20 @@
+2018-10-02  Basuke Suzuki  <Basuke.Suzuki@sony.com>
+
+        [Curl] Fix missing values of  resource timing API.
+        https://bugs.webkit.org/show_bug.cgi?id=190193
+
+        Reviewed by Alex Christensen.
+
+        The property nextHopProtocol was not returned correctly. It was
+        returned only when remote inspector is opened.
+
+        Tests: http/wpt/resource-timing/rt-nextHopProtocol.html
+               http/wpt/resource-timing/rt-nextHopProtocol.worker.html
+
+        * platform/network/curl/CurlContext.cpp:
+        (WebCore::CurlHandle::getNetworkLoadMetrics):
+        (WebCore::CurlHandle::addExtraNetworkLoadMetrics):
+
 2018-10-02  Alex Christensen  <achristensen@webkit.org>
 
         Remove unused linked-on-or-before-iOS5 check
index 5c8ad58..f79ba8f 100644 (file)
@@ -733,6 +733,7 @@ std::optional<NetworkLoadMetrics> CurlHandle::getNetworkLoadMetrics(const WTF::S
     double connect = 0.0;
     double appConnect = 0.0;
     double startTransfer = 0.0;
+    long version = 0;
 
     if (!m_handle)
         return std::nullopt;
@@ -753,6 +754,10 @@ std::optional<NetworkLoadMetrics> CurlHandle::getNetworkLoadMetrics(const WTF::S
     if (errorCode != CURLE_OK)
         return std::nullopt;
 
+    errorCode = curl_easy_getinfo(m_handle, CURLINFO_HTTP_VERSION, &version);
+    if (errorCode != CURLE_OK)
+        return std::nullopt;
+
     NetworkLoadMetrics networkLoadMetrics;
 
     networkLoadMetrics.domainLookupStart = domainLookupStart;
@@ -768,6 +773,13 @@ std::optional<NetworkLoadMetrics> CurlHandle::getNetworkLoadMetrics(const WTF::S
     networkLoadMetrics.requestStart = networkLoadMetrics.connectEnd;
     networkLoadMetrics.responseStart = domainLookupStart + Seconds(startTransfer);
 
+    if (version == CURL_HTTP_VERSION_1_0)
+        networkLoadMetrics.protocol = httpVersion10;
+    else if (version == CURL_HTTP_VERSION_1_1)
+        networkLoadMetrics.protocol = httpVersion11;
+    else if (version == CURL_HTTP_VERSION_2)
+        networkLoadMetrics.protocol = httpVersion2;
+
     return networkLoadMetrics;
 }
 
@@ -777,7 +789,6 @@ void CurlHandle::addExtraNetworkLoadMetrics(NetworkLoadMetrics& networkLoadMetri
     curl_off_t requestBodySize = 0;
     long responseHeaderSize = 0;
     curl_off_t responseBodySize = 0;
-    long version = 0;
     char* ip = nullptr;
     long port = 0;
 
@@ -806,10 +817,6 @@ void CurlHandle::addExtraNetworkLoadMetrics(NetworkLoadMetrics& networkLoadMetri
     if (errorCode != CURLE_OK)
         return;
 
-    errorCode = curl_easy_getinfo(m_handle, CURLINFO_HTTP_VERSION, &version);
-    if (errorCode != CURLE_OK)
-        return;
-
     networkLoadMetrics.requestHeaderBytesSent = requestHeaderSize;
     networkLoadMetrics.requestBodyBytesSent = requestBodySize;
     networkLoadMetrics.responseHeaderBytesReceived = responseHeaderSize;
@@ -820,13 +827,6 @@ void CurlHandle::addExtraNetworkLoadMetrics(NetworkLoadMetrics& networkLoadMetri
         if (port)
             networkLoadMetrics.remoteAddress.append(":" + String::number(port));
     }
-
-    if (version == CURL_HTTP_VERSION_1_0)
-        networkLoadMetrics.protocol = httpVersion10;
-    else if (version == CURL_HTTP_VERSION_1_1)
-        networkLoadMetrics.protocol = httpVersion11;
-    else if (version == CURL_HTTP_VERSION_2)
-        networkLoadMetrics.protocol = httpVersion2;
 }
 
 std::optional<CertificateInfo> CurlHandle::certificateInfo() const