diff options
author | Dan Winship <danw@gnome.org> | 2012-07-09 13:44:42 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-07-13 16:26:55 -0400 |
commit | ce65958b63582548675aa598d5126be798e1e866 (patch) | |
tree | 83fc61403411b8d5e5084c6e909b9176d7f7e836 /tests/coding-test.c | |
parent | da4f5b9e2b83771b23dbcfde62499425fe066e93 (diff) | |
download | libsoup-ce65958b63582548675aa598d5126be798e1e866.tar.gz libsoup-ce65958b63582548675aa598d5126be798e1e866.tar.bz2 libsoup-ce65958b63582548675aa598d5126be798e1e866.zip |
Add some test-utils helpers for async SoupRequest usage
Diffstat (limited to 'tests/coding-test.c')
-rw-r--r-- | tests/coding-test.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/tests/coding-test.c b/tests/coding-test.c index 47f5d085..8c68a35b 100644 --- a/tests/coding-test.c +++ b/tests/coding-test.c @@ -304,22 +304,6 @@ do_coding_test (void) } static void -req_sent (GObject *req, GAsyncResult *result, gpointer user_data) -{ - GInputStream **stream = user_data; - GError *error = NULL; - - *stream = soup_request_send_finish (SOUP_REQUEST (req), - result, &error); - if (error) { - debug_printf (1, " Error sending request: %s\n", - error->message); - g_error_free (error); - errors++; - } -} - -static void read_finished (GObject *stream, GAsyncResult *result, gpointer user_data) { gssize *nread = user_data; @@ -348,14 +332,19 @@ do_single_coding_req_test (SoupRequest *req, gssize nread; GError *error = NULL; + data = g_byte_array_new (); + msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req)); - stream = NULL; - soup_request_send_async (req, NULL, req_sent, &stream); - while (!stream) - g_main_context_iteration (NULL, TRUE); + stream = soup_test_request_send_async_as_sync (req, NULL, &error); + if (error) { + debug_printf (1, " Error sending request: %s\n", + error->message); + g_error_free (error); + errors++; + return data; + } - data = g_byte_array_new (); do { nread = -2; g_input_stream_read_async (stream, buf, sizeof (buf), @@ -368,7 +357,7 @@ do_single_coding_req_test (SoupRequest *req, g_byte_array_append (data, buf, nread); } while (nread > 0); - g_input_stream_close (stream, NULL, &error); + soup_test_stream_close_async_as_sync (stream, NULL, &error); if (error) { debug_printf (1, " error closing stream: %s\n", error->message); |