Web Inspector: Do not try to parse incomplete HTTP requests
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2013 15:49:55 +0000 (15:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2013 15:49:55 +0000 (15:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121123

Patch by Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> on 2013-09-16
Reviewed by Carlos Garcia Campos.

Update to incorporate additional review suggestions.

* UIProcess/API/gtk/tests/TestInspectorServer.cpp:
(sendIncompleteRequest):
Fix memory leaks, change test timeout from 2 seconds to 1 second,
use "0" instead of "NULL" and use g_assert_no_error when checking
for GError.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp

index 38f2293a9cec6dfd165176ea065e6b96bcb0e558..ef2c0b7cf2da90d99a2ab2ed1bca8c979d908b01 100644 (file)
@@ -1,3 +1,18 @@
+2013-09-16  Andre Moreira Magalhaes   <andre.magalhaes@collabora.co.uk>
+
+        Web Inspector: Do not try to parse incomplete HTTP requests
+        https://bugs.webkit.org/show_bug.cgi?id=121123
+
+        Reviewed by Carlos Garcia Campos.
+
+        Update to incorporate additional review suggestions.
+
+        * UIProcess/API/gtk/tests/TestInspectorServer.cpp:
+        (sendIncompleteRequest):
+        Fix memory leaks, change test timeout from 2 seconds to 1 second,
+        use "0" instead of "NULL" and use g_assert_no_error when checking
+        for GError.
+
 2013-09-16  Eunmi Lee  <eunmi15.lee@samsung.com>
 
         [EFL][WK2] Implement pan and flick gesture.
index b0468bfbf77481ee0307019351eb8e33de447a32..fa4cb4fa09cfc6e4e60c7568a7486576f00ff69f 100644 (file)
@@ -245,27 +245,29 @@ static void sendIncompleteRequest(InspectorServerTest* test, gconstpointer)
     GOwnPtr<GError> error;
 
     // Connect to the inspector server.
-    GSocketClient* client = g_socket_client_new();
-    GSocketConnection* connection = g_socket_client_connect_to_host(client, "127.0.0.1", 2999, NULL, &error.outPtr());
-    g_assert(!error.get());
+    GRefPtr<GSocketClient> client = adoptGRef(g_socket_client_new());
+    GRefPtr<GSocketConnection> connection = adoptGRef(g_socket_client_connect_to_host(client.get(), "127.0.0.1", 2999, 0, &error.outPtr()));
+    g_assert_no_error(error.get());
 
     // Send incomplete request (missing blank line after headers) and check if inspector server
     // replies. The server should not reply to an incomplete request and the test should timeout
     // on read.
-    GOutputStream* ostream = g_io_stream_get_output_stream(G_IO_STREAM(connection));
+    GOutputStream* ostream = g_io_stream_get_output_stream(G_IO_STREAM(connection.get()));
     // Request missing blank line after headers.
     const gchar* incompleteRequest = "GET /devtools/page/1 HTTP/1.1\r\nHost: Localhost\r\n";
-    g_output_stream_write(ostream, incompleteRequest, strlen(incompleteRequest), NULL, &error.outPtr());
-    g_assert(!error.get());
+    g_output_stream_write(ostream, incompleteRequest, strlen(incompleteRequest), 0, &error.outPtr());
+    g_assert_no_error(error.get());
 
-    GInputStream* istream = g_io_stream_get_input_stream(G_IO_STREAM(connection));
+    GInputStream* istream = g_io_stream_get_input_stream(G_IO_STREAM(connection.get()));
     char response[16];
     memset(response, 0, sizeof(response));
-    g_input_stream_read_async(istream, response, sizeof(response) - 1, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+    GRefPtr<GCancellable> cancel = adoptGRef(g_cancellable_new());
+    g_input_stream_read_async(istream, response, sizeof(response) - 1, G_PRIORITY_DEFAULT, cancel.get(), 0, 0);
     // Give a chance for the server to reply.
-    test->wait(2);
+    test->wait(1);
+    g_cancellable_cancel(cancel.get());
     // If we got any answer it means the server replied to an incomplete request, lets fail.
-    g_assert(String(response).isEmpty());
+    g_assert(response[0] == '\0');
 }
 
 void beforeAll()