Title: [272195] trunk
Revision
272195
Author
[email protected]
Date
2021-02-02 00:50:27 -0800 (Tue, 02 Feb 2021)

Log Message

[GTK][WPE] Migrate WebKitTestServer to libsoup 2.48 API
https://bugs.webkit.org/show_bug.cgi?id=219160
<rdar://problem/71620310>

Reviewed by Michael Catanzaro.

Source/WTF:

* wtf/Platform.h: Bump libsoup minimum required version to 2.54.

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
(serverCallback):
* TestWebKitAPI/Tests/WebKitGLib/TestCookieManager.cpp:
(serverCallback):
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
(serverCallback):
* TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp:
(WebKitTestServer::WebKitTestServer):
(WebKitTestServer::run):
(WebKitTestServer::port const):
* TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (272194 => 272195)


--- trunk/Source/WTF/ChangeLog	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Source/WTF/ChangeLog	2021-02-02 08:50:27 UTC (rev 272195)
@@ -1,3 +1,13 @@
+2021-02-02  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Migrate WebKitTestServer to libsoup 2.48 API
+        https://bugs.webkit.org/show_bug.cgi?id=219160
+        <rdar://problem/71620310>
+
+        Reviewed by Michael Catanzaro.
+
+        * wtf/Platform.h: Bump libsoup minimum required version to 2.54.
+
 2021-02-01  Mark Lam  <[email protected]>
 
         ConcurrentPtrHashSet::contains() should be const.

Modified: trunk/Source/WTF/wtf/Platform.h (272194 => 272195)


--- trunk/Source/WTF/wtf/Platform.h	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Source/WTF/wtf/Platform.h	2021-02-02 08:50:27 UTC (rev 272195)
@@ -96,7 +96,7 @@
 #endif
 
 #if USE(SOUP)
-#define SOUP_VERSION_MIN_REQUIRED SOUP_VERSION_2_42
+#define SOUP_VERSION_MIN_REQUIRED SOUP_VERSION_2_54
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Tools/ChangeLog (272194 => 272195)


--- trunk/Tools/ChangeLog	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/ChangeLog	2021-02-02 08:50:27 UTC (rev 272195)
@@ -1,3 +1,23 @@
+2021-02-02  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Migrate WebKitTestServer to libsoup 2.48 API
+        https://bugs.webkit.org/show_bug.cgi?id=219160
+        <rdar://problem/71620310>
+
+        Reviewed by Michael Catanzaro.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
+        (serverCallback):
+        * TestWebKitAPI/Tests/WebKitGLib/TestCookieManager.cpp:
+        (serverCallback):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
+        (serverCallback):
+        * TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp:
+        (WebKitTestServer::WebKitTestServer):
+        (WebKitTestServer::run):
+        (WebKitTestServer::port const):
+        * TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h:
+
 2021-02-01  Ryan Haddad  <[email protected]>
 
         Update Test262 bot to Big Sur

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp (272194 => 272195)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2021-02-02 08:50:27 UTC (rev 272195)
@@ -375,8 +375,9 @@
 
 static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext* context, void*)
 {
+    unsigned port = g_inet_socket_address_get_port(G_INET_SOCKET_ADDRESS((soup_client_context_get_local_address(context))));
     if (message->method == SOUP_METHOD_CONNECT) {
-        g_assert_cmpuint(soup_server_get_port(server), ==, gProxyServerPort);
+        g_assert_cmpuint(port, ==, gProxyServerPort);
         auto tunnel = makeUnique<Tunnel>(server, message);
         auto* tunnelPtr = tunnel.get();
         tunnelPtr->connect([tunnel = WTFMove(tunnel)](const char* errorMessage) {
@@ -399,7 +400,7 @@
     if (g_str_has_suffix(path, "/auth-test.html") || g_str_has_suffix(path, "/empty-realm.html")) {
         bool isProxy = g_str_has_prefix(path, "/proxy");
         if (isProxy)
-            g_assert_cmpuint(soup_server_get_port(server), ==, gProxyServerPort);
+            g_assert_cmpuint(port, ==, gProxyServerPort);
 
         const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization");
         // Require authentication.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestCookieManager.cpp (272194 => 272195)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestCookieManager.cpp	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestCookieManager.cpp	2021-02-02 08:50:27 UTC (rev 272195)
@@ -716,7 +716,7 @@
     gchar* header_str = g_strdup_printf("%s=%s; Max-Age=60", kCookieName, kCookieValue);
 
     if (g_str_equal(path, "/index.html")) {
-        char* indexHtml = g_strdup_printf(kIndexHtmlFormat, soup_server_get_port(server));
+        char* indexHtml = g_strdup_printf(kIndexHtmlFormat, kServer->port());
         soup_message_headers_replace(message->response_headers, "Set-Cookie", header_str);
         soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, indexHtml, strlen(indexHtml));
     } else if (g_str_equal(path, "/image.png"))

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp (272194 => 272195)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp	2021-02-02 08:50:27 UTC (rev 272195)
@@ -386,7 +386,7 @@
     g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
 }
 
-static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext* context, gpointer)
 {
     if (message->method != SOUP_METHOD_GET) {
         soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
@@ -404,7 +404,7 @@
         soup_message_body_complete(message->response_body);
         soup_message_set_status(message, SOUP_STATUS_OK);
     } else if (g_str_equal(path, "/echoPort")) {
-        char* port = g_strdup_printf("%u", soup_server_get_port(server));
+        char* port = g_strdup_printf("%u", g_inet_socket_address_get_port(G_INET_SOCKET_ADDRESS((soup_client_context_get_local_address(context)))));
         soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, port, strlen(port));
         soup_message_body_complete(message->response_body);
         soup_message_set_status(message, SOUP_STATUS_OK);

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp (272194 => 272195)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.cpp	2021-02-02 08:50:27 UTC (rev 272195)
@@ -23,6 +23,7 @@
 #include "TestMain.h"
 #include <wtf/Threading.h>
 #include <wtf/glib/GUniquePtr.h>
+#include <wtf/threads/BinarySemaphore.h>
 
 WebKitTestServer::WebKitTestServer(ServerOptions options)
 {
@@ -31,23 +32,14 @@
         m_queue = WorkQueue::create("WebKitTestServer");
     }
 
-    GUniquePtr<char> sslCertificateFile;
-    GUniquePtr<char> sslKeyFile;
+    m_soupServer = adoptGRef(soup_server_new("server-header", "WebKitTestServer ", nullptr));
+
     if (options & ServerHTTPS) {
         CString resourcesDir = Test::getResourcesDir();
-        sslCertificateFile.reset(g_build_filename(resourcesDir.data(), "test-cert.pem", NULL));
-        sslKeyFile.reset(g_build_filename(resourcesDir.data(), "test-key.pem", NULL));
+        GUniquePtr<char> sslCertificateFile(g_build_filename(resourcesDir.data(), "test-cert.pem", nullptr));
+        GUniquePtr<char> sslKeyFile(g_build_filename(resourcesDir.data(), "test-key.pem", nullptr));
+        g_assert_true(soup_server_set_ssl_cert_file(m_soupServer.get(), sslCertificateFile.get(), sslKeyFile.get(), nullptr));
     }
-
-    GRefPtr<SoupAddress> address = adoptGRef(soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT));
-    soup_address_resolve_sync(address.get(), 0);
-
-    m_soupServer = adoptGRef(soup_server_new(SOUP_SERVER_INTERFACE, address.get(),
-        SOUP_SERVER_ASYNC_CONTEXT, m_queue ? m_queue->runLoop().mainContext() : nullptr,
-        SOUP_SERVER_SSL_CERT_FILE, sslCertificateFile.get(),
-        SOUP_SERVER_SSL_KEY_FILE, sslKeyFile.get(), nullptr));
-    m_baseURI = options & ServerHTTPS ? soup_uri_new("https://127.0.0.1/") : soup_uri_new("http://127.0.0.1/");
-    soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer.get()));
 }
 
 WebKitTestServer::~WebKitTestServer()
@@ -59,15 +51,26 @@
 
 void WebKitTestServer::run(SoupServerCallback serverCallback)
 {
+    soup_server_add_handler(m_soupServer.get(), nullptr, serverCallback, nullptr, nullptr);
+
+    unsigned options = SOUP_SERVER_LISTEN_IPV4_ONLY;
+    if (soup_server_is_https(m_soupServer.get()))
+        options |= SOUP_SERVER_LISTEN_HTTPS;
+
     if (m_queue) {
-        m_queue->dispatch([this, serverCallback] {
-            soup_server_run_async(m_soupServer.get());
-            soup_server_add_handler(m_soupServer.get(), nullptr, serverCallback, nullptr, nullptr);
+        BinarySemaphore semaphore;
+        m_queue->dispatch([&] {
+            g_assert_true(soup_server_listen_local(m_soupServer.get(), SOUP_ADDRESS_ANY_PORT, static_cast<SoupServerListenOptions>(options), nullptr));
+            semaphore.signal();
         });
-    } else {
-        soup_server_run_async(m_soupServer.get());
-        soup_server_add_handler(m_soupServer.get(), nullptr, serverCallback, nullptr, nullptr);
-    }
+        semaphore.wait();
+    } else
+        g_assert_true(soup_server_listen_local(m_soupServer.get(), SOUP_ADDRESS_ANY_PORT, static_cast<SoupServerListenOptions>(options), nullptr));
+
+    GSList* uris = soup_server_get_uris(m_soupServer.get());
+    g_assert_nonnull(uris);
+    m_baseURI = soup_uri_copy(static_cast<SoupURI*>(uris->data));
+    g_slist_free_full(uris, reinterpret_cast<GDestroyNotify>(soup_uri_free));
 }
 
 void WebKitTestServer::addWebSocketHandler(SoupServerWebsocketCallback callback, gpointer userData)
@@ -113,3 +116,8 @@
     soup_uri_free(uri);
     return uriString.get();
 }
+
+unsigned WebKitTestServer::port() const
+{
+    return soup_uri_get_port(m_baseURI);
+}

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h (272194 => 272195)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h	2021-02-02 08:34:53 UTC (rev 272194)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebKitTestServer.h	2021-02-02 08:50:27 UTC (rev 272195)
@@ -38,6 +38,7 @@
     virtual ~WebKitTestServer();
 
     SoupURI* baseURI() const { return m_baseURI; }
+    unsigned port() const;
     CString getURIForPath(const char* path) const;
     void run(SoupServerCallback);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to