Title: [226954] trunk/Source/WebCore
Revision
226954
Author
[email protected]
Date
2018-01-15 13:21:53 -0800 (Mon, 15 Jan 2018)

Log Message

[Curl] Enable HTTP/2
https://bugs.webkit.org/show_bug.cgi?id=181551

Patch by Basuke Suzuki <[email protected]> on 2018-01-15
Reviewed by Michael Catanzaro.

Start supporting HTTP/2 protocol. The first step is just enabling the HTTP/2 on Curl backend.
Next step will be to enable multiplexing feature.

No new tests because we don't have HTTP/2 test backend yet.

* platform/network/curl/CurlContext.cpp:
(WebCore::CurlContext::isHttp2Enabled const):
(WebCore::CurlHandle::enableHttp):
(WebCore::CurlHandle::enableHttpGetRequest):
(WebCore::CurlHandle::enableHttpHeadRequest):
(WebCore::CurlHandle::enableHttpPostRequest):
(WebCore::CurlHandle::enableHttpPutRequest):
(WebCore::CurlHandle::setHttpCustomRequest):
* platform/network/curl/CurlContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226953 => 226954)


--- trunk/Source/WebCore/ChangeLog	2018-01-15 20:43:39 UTC (rev 226953)
+++ trunk/Source/WebCore/ChangeLog	2018-01-15 21:21:53 UTC (rev 226954)
@@ -1,3 +1,25 @@
+2018-01-15  Basuke Suzuki  <[email protected]>
+
+        [Curl] Enable HTTP/2
+        https://bugs.webkit.org/show_bug.cgi?id=181551
+
+        Reviewed by Michael Catanzaro.
+
+        Start supporting HTTP/2 protocol. The first step is just enabling the HTTP/2 on Curl backend.
+        Next step will be to enable multiplexing feature.
+
+        No new tests because we don't have HTTP/2 test backend yet.
+
+        * platform/network/curl/CurlContext.cpp:
+        (WebCore::CurlContext::isHttp2Enabled const):
+        (WebCore::CurlHandle::enableHttp):
+        (WebCore::CurlHandle::enableHttpGetRequest):
+        (WebCore::CurlHandle::enableHttpHeadRequest):
+        (WebCore::CurlHandle::enableHttpPostRequest):
+        (WebCore::CurlHandle::enableHttpPutRequest):
+        (WebCore::CurlHandle::setHttpCustomRequest):
+        * platform/network/curl/CurlContext.h:
+
 2018-01-15  Dean Jackson  <[email protected]>
 
         Use a helper function for checked arithmetic in WebGL validation

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.cpp (226953 => 226954)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2018-01-15 20:43:39 UTC (rev 226953)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2018-01-15 21:21:53 UTC (rev 226954)
@@ -157,8 +157,12 @@
     setProxyInfo(info);
 }
 
+bool CurlContext::isHttp2Enabled() const
+{
+    curl_version_info_data* data = ""
+    return data->features & CURL_VERSION_HTTP2;
+}
 
-
 // CurlShareHandle --------------------------------------------
 
 CurlShareHandle::CurlShareHandle()
@@ -359,18 +363,32 @@
     curl_easy_setopt(m_handle, CURLOPT_HTTPHEADER, headers);
 }
 
+void CurlHandle::enableHttp()
+{
+    if (CurlContext::singleton().isHttp2Enabled()) {
+        curl_easy_setopt(m_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
+        curl_easy_setopt(m_handle, CURLOPT_PIPEWAIT, 1L);
+        curl_easy_setopt(m_handle, CURLOPT_SSL_ENABLE_ALPN, 1L);
+        curl_easy_setopt(m_handle, CURLOPT_SSL_ENABLE_NPN, 0L);
+    } else
+        curl_easy_setopt(m_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+}
+
 void CurlHandle::enableHttpGetRequest()
 {
+    enableHttp();
     curl_easy_setopt(m_handle, CURLOPT_HTTPGET, 1L);
 }
 
 void CurlHandle::enableHttpHeadRequest()
 {
+    enableHttp();
     curl_easy_setopt(m_handle, CURLOPT_NOBODY, 1L);
 }
 
 void CurlHandle::enableHttpPostRequest()
 {
+    enableHttp();
     curl_easy_setopt(m_handle, CURLOPT_POST, 1L);
     curl_easy_setopt(m_handle, CURLOPT_POSTFIELDSIZE, 0L);
 }
@@ -391,6 +409,7 @@
 
 void CurlHandle::enableHttpPutRequest()
 {
+    enableHttp();
     curl_easy_setopt(m_handle, CURLOPT_UPLOAD, 1L);
     curl_easy_setopt(m_handle, CURLOPT_INFILESIZE, 0L);
 }
@@ -405,6 +424,7 @@
 
 void CurlHandle::setHttpCustomRequest(const String& method)
 {
+    enableHttp();
     curl_easy_setopt(m_handle, CURLOPT_CUSTOMREQUEST, method.ascii().data());
 }
 

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.h (226953 => 226954)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.h	2018-01-15 20:43:39 UTC (rev 226953)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.h	2018-01-15 21:21:53 UTC (rev 226954)
@@ -123,6 +123,9 @@
     // SSL
     CurlSSLHandle& sslHandle() { return m_sslHandle; }
 
+    // HTTP/2
+    bool isHttp2Enabled() const;
+
 #ifndef NDEBUG
     FILE* getLogFile() const { return m_logFile; }
     bool isVerbose() const { return m_verbose; }
@@ -230,6 +233,7 @@
     void appendRequestHeader(const String& name);
     void removeRequestHeader(const String& name);
 
+    void enableHttp();
     void enableHttpGetRequest();
     void enableHttpHeadRequest();
     void enableHttpPostRequest();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to