Skip to content

Commit

Permalink
Merge r155861 - Web Inspector: Do not try to parse incomplete HTTP re…
Browse files Browse the repository at this point in the history
…quests

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.
  • Loading branch information
andrunko authored and carlosgcampos committed Sep 16, 2013
1 parent 26333ba commit 76ac050
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 15 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -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-12 Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk>

Web Inspector: Do not try to parse incomplete HTTP requests
Expand Down
22 changes: 12 additions & 10 deletions Source/WebKit2/UIProcess/API/gtk/tests/TestInspectorServer.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit 76ac050

Please sign in to comment.