Title: [258393] trunk/Source/WebKit
Revision
258393
Author
carlo...@webkit.org
Date
2020-03-13 03:37:53 -0700 (Fri, 13 Mar 2020)

Log Message

[SOUP] Notify web process about WebSocket handshake request and response
https://bugs.webkit.org/show_bug.cgi?id=208994

Reviewed by Youenn Fablet.

This makes WebSockets appear again in web inspector.

* NetworkProcess/soup/WebSocketTaskSoup.cpp:
(WebKit::WebSocketTask::WebSocketTask): Save the handshake message and notify the channel when the request is sent.
(WebKit::WebSocketTask::didConnect): Notify the channel that handshake response has been received.
(WebKit::WebSocketTask::didFail): Notify the channel that handshake response has been received if handshake
failed.
* NetworkProcess/soup/WebSocketTaskSoup.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (258392 => 258393)


--- trunk/Source/WebKit/ChangeLog	2020-03-13 10:31:45 UTC (rev 258392)
+++ trunk/Source/WebKit/ChangeLog	2020-03-13 10:37:53 UTC (rev 258393)
@@ -1,3 +1,19 @@
+2020-03-13  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [SOUP] Notify web process about WebSocket handshake request and response
+        https://bugs.webkit.org/show_bug.cgi?id=208994
+
+        Reviewed by Youenn Fablet.
+
+        This makes WebSockets appear again in web inspector.
+
+        * NetworkProcess/soup/WebSocketTaskSoup.cpp:
+        (WebKit::WebSocketTask::WebSocketTask): Save the handshake message and notify the channel when the request is sent.
+        (WebKit::WebSocketTask::didConnect): Notify the channel that handshake response has been received.
+        (WebKit::WebSocketTask::didFail): Notify the channel that handshake response has been received if handshake
+        failed.
+        * NetworkProcess/soup/WebSocketTaskSoup.h:
+
 2020-03-13  Youenn Fablet  <you...@apple.com>
 
         Apply rotation at source level if WebRTC sink ask so

Modified: trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp (258392 => 258393)


--- trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp	2020-03-13 10:31:45 UTC (rev 258392)
+++ trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp	2020-03-13 10:37:53 UTC (rev 258393)
@@ -29,6 +29,8 @@
 #include "DataReference.h"
 #include "NetworkSocketChannel.h"
 #include <WebCore/HTTPParsers.h>
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
 #include <WebCore/WebSocketChannel.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/StringBuilder.h>
@@ -37,6 +39,7 @@
 
 WebSocketTask::WebSocketTask(NetworkSocketChannel& channel, SoupSession* session, SoupMessage* msg, const String& protocol)
     : m_channel(channel)
+    , m_handshakeMessage(msg)
     , m_cancellable(adoptGRef(g_cancellable_new()))
 {
     auto protocolList = protocol.split(',');
@@ -65,6 +68,10 @@
             else
                 task->didFail(String::fromUTF8(error->message));
         }, this);
+
+    WebCore::ResourceRequest request;
+    request.updateFromSoupMessage(msg);
+    m_channel.didSendHandshakeRequest(WTFMove(request));
 }
 
 WebSocketTask::~WebSocketTask()
@@ -109,6 +116,11 @@
     g_signal_connect_swapped(m_connection.get(), "closed", reinterpret_cast<GCallback>(didCloseCallback), this);
 
     m_channel.didConnect(soup_websocket_connection_get_protocol(m_connection.get()), acceptedExtensions());
+
+    WebCore::ResourceResponse response;
+    response.updateFromSoupMessage(m_handshakeMessage.get());
+    m_channel.didReceiveHandshakeResponse(WTFMove(response));
+    m_handshakeMessage = nullptr;
 }
 
 void WebSocketTask::didReceiveMessageCallback(WebSocketTask* task, SoupWebsocketDataType dataType, GBytes* message)
@@ -143,6 +155,12 @@
         return;
 
     m_receivedDidFail = true;
+    if (m_handshakeMessage) {
+        WebCore::ResourceResponse response;
+        response.updateFromSoupMessage(m_handshakeMessage.get());
+        m_channel.didReceiveHandshakeResponse(WTFMove(response));
+        m_handshakeMessage = nullptr;
+    }
     m_channel.didReceiveMessageError(errorMessage);
     if (!m_connection) {
         didClose(SOUP_WEBSOCKET_CLOSE_ABNORMAL, { });

Modified: trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h (258392 => 258393)


--- trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h	2020-03-13 10:31:45 UTC (rev 258392)
+++ trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h	2020-03-13 10:37:53 UTC (rev 258393)
@@ -60,6 +60,7 @@
     static void didCloseCallback(WebSocketTask*);
 
     NetworkSocketChannel& m_channel;
+    GRefPtr<SoupMessage> m_handshakeMessage;
     GRefPtr<SoupWebsocketConnection> m_connection;
     GRefPtr<GCancellable> m_cancellable;
     bool m_receivedDidFail { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to