[libsoup/carlosgc/simple-api: 15/16] tests: stop using SoupRequest API in tests




commit 7ab4f3f36bbf7c96ef19e378477c0eba84e1f3a3
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Oct 19 13:13:23 2020 +0200

    tests: stop using SoupRequest API in tests

 tests/cache-test.c      |  31 +++----
 tests/coding-test.c     | 193 +-------------------------------------------
 tests/connection-test.c |  91 ---------------------
 tests/misc-test.c       | 210 +-----------------------------------------------
 tests/multipart-test.c  |  63 ++++++---------
 tests/proxy-test.c      |  75 +----------------
 tests/redirect-test.c   |  92 ---------------------
 tests/sniffing-test.c   |  45 ++---------
 tests/test-utils.c      |  40 ++++-----
 tests/test-utils.h      |   9 +--
 tests/timeout-test.c    | 101 -----------------------
 11 files changed, 79 insertions(+), 871 deletions(-)
---
diff --git a/tests/cache-test.c b/tests/cache-test.c
index a048db57..454f0d4b 100644
--- a/tests/cache-test.c
+++ b/tests/cache-test.c
@@ -148,7 +148,6 @@ do_request (SoupSession        *session,
            SoupMessageHeaders *response_headers,
            ...)
 {
-       SoupRequestHTTP *req;
        SoupMessage *msg;
        GInputStream *stream;
        SoupURI *uri;
@@ -162,9 +161,8 @@ do_request (SoupSession        *session,
        last_request_unqueued = FALSE;
 
        uri = soup_uri_new_with_base (base_uri, path);
-       req = soup_session_request_http_uri (session, method, uri, NULL);
+       msg = soup_message_new_from_uri (method, uri);
        soup_uri_free (uri);
-       msg = soup_request_http_get_message (req);
 
        va_start (ap, response_headers);
        while ((header = va_arg (ap, const char *))) {
@@ -174,12 +172,11 @@ do_request (SoupSession        *session,
        }
        va_end (ap);
 
-       stream = soup_test_request_send (SOUP_REQUEST (req), NULL, 0, &error);
+       stream = soup_test_request_send (session, msg, NULL, 0, &error);
        if (!stream) {
                debug_printf (1, "    could not send request: %s\n",
                              error->message);
                g_error_free (error);
-               g_object_unref (req);
                g_object_unref (msg);
                return NULL;
        }
@@ -204,15 +201,13 @@ do_request (SoupSession        *session,
                              error->message);
                g_clear_error (&error);
        }
-       soup_test_request_close_stream (SOUP_REQUEST (req), stream,
-                                       NULL, &error);
+       soup_test_request_close_stream (stream, NULL, &error);
        if (error) {
                debug_printf (1, "    could not close stream: %s\n",
                              error->message);
                g_clear_error (&error);
        }
        g_object_unref (stream);
-       g_object_unref (req);
 
        /* Cache writes are G_PRIORITY_LOW, so they won't have happened yet... */
        soup_cache_flush ((SoupCache *)soup_session_get_feature (session, SOUP_TYPE_CACHE));
@@ -227,7 +222,7 @@ do_request_with_cancel (SoupSession          *session,
                        const char           *path,
                        SoupTestRequestFlags  flags)
 {
-       SoupRequestHTTP *req;
+       SoupMessage *msg;
        GInputStream *stream;
        SoupURI *uri;
        GError *error = NULL;
@@ -237,21 +232,21 @@ do_request_with_cancel (SoupSession          *session,
        cancelled_requests = 0;
 
        uri = soup_uri_new_with_base (base_uri, path);
-       req = soup_session_request_http_uri (session, method, uri, NULL);
+       msg = soup_message_new_from_uri (method, uri);
        soup_uri_free (uri);
        cancellable = flags & SOUP_TEST_REQUEST_CANCEL_CANCELLABLE ? g_cancellable_new () : NULL;
-       stream = soup_test_request_send (SOUP_REQUEST (req), cancellable, flags, &error);
+       stream = soup_test_request_send (session, msg, cancellable, flags, &error);
        if (stream) {
                debug_printf (1, "    could not cancel the request\n");
                g_object_unref (stream);
-               g_object_unref (req);
+               g_object_unref (msg);
                return;
        } else
                g_clear_error (&error);
 
        g_clear_object (&cancellable);
        g_clear_object (&stream);
-       g_clear_object (&req);
+       g_clear_object (&msg);
 
        soup_cache_flush ((SoupCache *)soup_session_get_feature (session, SOUP_TYPE_CACHE));
 }
@@ -575,7 +570,7 @@ do_refcounting_test (gconstpointer data)
        SoupSession *session;
        SoupCache *cache;
        char *cache_dir;
-       SoupRequestHTTP *req;
+       SoupMessage *msg;
        GInputStream *stream, *base_stream;
        SoupURI *uri;
        GError *error = NULL;
@@ -595,19 +590,19 @@ do_refcounting_test (gconstpointer data)
        cancelled_requests = 0;
 
        uri = soup_uri_new_with_base (base_uri, "/1");
-       req = soup_session_request_http_uri (session, "GET", uri, NULL);
+       msg = soup_message_new_from_uri ("GET", uri);
        soup_uri_free (uri);
 
        flags = SOUP_TEST_REQUEST_CANCEL_AFTER_SEND_FINISH | SOUP_TEST_REQUEST_CANCEL_MESSAGE;
-       stream = soup_test_request_send (SOUP_REQUEST (req), NULL, flags, &error);
+       stream = soup_test_request_send (session, msg, NULL, flags, &error);
        if (!stream) {
                debug_printf (1, "    could not send request: %s\n",
                              error->message);
                g_error_free (error);
-               g_object_unref (req);
+               g_object_unref (msg);
                return;
        }
-       g_object_unref (req);
+       g_object_unref (msg);
 
        base_stream = g_filter_input_stream_get_base_stream (G_FILTER_INPUT_STREAM (stream));
 
diff --git a/tests/coding-test.c b/tests/coding-test.c
index 75233351..31488950 100644
--- a/tests/coding-test.c
+++ b/tests/coding-test.c
@@ -128,15 +128,13 @@ server_callback (SoupServer        *server,
 typedef struct {
        SoupSession *session;
        SoupMessage *msg;
-       SoupRequest *req;
        GBytes *response;
 } CodingTestData;
 
 typedef enum {
        CODING_TEST_DEFAULT     = 0,
        CODING_TEST_NO_DECODER  = (1 << 0),
-       CODING_TEST_REQUEST_API = (1 << 1),
-       CODING_TEST_EMPTY       = (1 << 2)
+       CODING_TEST_EMPTY       = (1 << 1)
 } CodingTestType;
 
 typedef enum {
@@ -192,14 +190,7 @@ setup_coding_test (CodingTestData *data, gconstpointer test_data)
                g_object_unref (msg);
        }
 
-       if (test_type & CODING_TEST_REQUEST_API) {
-               SoupRequestHTTP *reqh;
-
-               reqh = soup_session_request_http_uri (data->session, "GET", uri, NULL);
-               data->req = SOUP_REQUEST (reqh);
-               data->msg = soup_request_http_get_message (reqh);
-       } else
-               data->msg = soup_message_new_from_uri ("GET", uri);
+       data->msg = soup_message_new_from_uri ("GET", uri);
        soup_uri_free (uri);
 
        if (test_type & CODING_TEST_NO_DECODER)
@@ -210,8 +201,6 @@ static void
 teardown_coding_test (CodingTestData *data, gconstpointer test_data)
 {
        g_bytes_unref (data->response);
-
-       g_clear_object (&data->req);
        g_object_unref (data->msg);
 
        soup_test_session_abort_unref (data->session);
@@ -340,143 +329,6 @@ do_coding_test_deflate_raw_bad_server (CodingTestData *data, gconstpointer test_
        g_bytes_unref (body);
 }
 
-static void
-read_finished (GObject *stream, GAsyncResult *result, gpointer user_data)
-{
-       gssize *nread = user_data;
-       GError *error = NULL;
-
-       *nread = g_input_stream_read_finish (G_INPUT_STREAM (stream),
-                                            result, &error);
-       g_assert_no_error (error);
-       g_clear_error (&error);
-}
-
-static void
-do_single_coding_req_test (CodingTestData *data,
-                          const char *expected_encoding,
-                          const char *expected_content_type,
-                          MessageContentStatus status)
-{
-       GInputStream *stream;
-       GByteArray *body;
-        GBytes *body_bytes;
-       guchar buf[1024];
-       gssize nread;
-       GError *error = NULL;
-
-       body = g_byte_array_new ();
-
-       stream = soup_test_request_send (data->req, NULL, 0, &error);
-       if (!stream) {
-               g_assert_no_error (error);
-               g_error_free (error);
-               return;
-       }
-
-       do {
-               nread = -2;
-               g_input_stream_read_async (stream, buf, sizeof (buf),
-                                          G_PRIORITY_DEFAULT,
-                                          NULL, read_finished, &nread);
-               while (nread == -2)
-                       g_main_context_iteration (NULL, TRUE);
-
-               if (nread > 0)
-                       g_byte_array_append (body, buf, nread);
-       } while (nread > 0);
-
-       soup_test_request_close_stream (data->req, stream, NULL, &error);
-       g_assert_no_error (error);
-       g_clear_error (&error);
-       g_object_unref (stream);
-
-        body_bytes = g_byte_array_free_to_bytes (body);
-       check_response (data, expected_encoding, expected_content_type, status, body_bytes);
-       g_bytes_unref (body_bytes);
-}
-
-static void
-do_coding_req_test_plain (CodingTestData *data, gconstpointer test_data)
-{
-       do_single_coding_req_test (data, NULL, "text/plain", EXPECT_NOT_DECODED);
-}
-
-static void
-do_coding_req_test_gzip (CodingTestData *data, gconstpointer test_data)
-{
-       do_single_coding_req_test (data, "gzip", "text/plain", EXPECT_DECODED);
-}
-
-static void
-do_coding_req_test_gzip_with_junk (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("606352");
-       g_test_bug ("676477");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "trailing-junk");
-
-       do_single_coding_req_test (data, "gzip", "text/plain", EXPECT_DECODED);
-}
-
-static void
-do_coding_req_test_gzip_bad_server (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("613361");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "force-encode");
-       do_single_coding_req_test (data, "gzip", "text/plain", EXPECT_NOT_DECODED);
-}
-
-static void
-do_coding_req_test_deflate (CodingTestData *data, gconstpointer test_data)
-{
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "prefer-deflate-zlib");
-       do_single_coding_req_test (data, "deflate", "text/plain", EXPECT_DECODED);
-}
-
-static void
-do_coding_req_test_deflate_with_junk (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("606352");
-       g_test_bug ("676477");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "prefer-deflate-zlib, trailing-junk");
-       do_single_coding_req_test (data, "deflate", "text/plain", EXPECT_DECODED);
-}
-
-static void
-do_coding_req_test_deflate_bad_server (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("613361");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "force-encode, prefer-deflate-zlib");
-       do_single_coding_req_test (data, "deflate", "text/plain", EXPECT_NOT_DECODED);
-}
-
-static void
-do_coding_req_test_deflate_raw (CodingTestData *data, gconstpointer test_data)
-{
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "prefer-deflate-raw");
-       do_single_coding_req_test (data, "deflate", "text/plain", EXPECT_DECODED);
-}
-
-static void
-do_coding_req_test_deflate_raw_bad_server (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("613361");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "force-encode, prefer-deflate-raw");
-       do_single_coding_req_test (data, "deflate", "text/plain", EXPECT_NOT_DECODED);
-}
-
 static void
 do_coding_msg_empty_test (CodingTestData *data, gconstpointer test_data)
 {
@@ -491,16 +343,6 @@ do_coding_msg_empty_test (CodingTestData *data, gconstpointer test_data)
        g_bytes_unref (body);
 }
 
-static void
-do_coding_req_empty_test (CodingTestData *data, gconstpointer test_data)
-{
-       g_test_bug ("697527");
-
-       soup_message_headers_append (data->msg->request_headers,
-                                    "X-Test-Options", "empty");
-       do_single_coding_req_test (data, "gzip", "text/plain", EXPECT_NOT_DECODED);
-}
-
 int
 main (int argc, char **argv)
 {
@@ -540,40 +382,9 @@ main (int argc, char **argv)
                    GINT_TO_POINTER (CODING_TEST_DEFAULT),
                    setup_coding_test, do_coding_test_deflate_raw_bad_server, teardown_coding_test);
 
-       g_test_add ("/coding/request/plain", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_NO_DECODER | CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_plain, teardown_coding_test);
-       g_test_add ("/coding/request/gzip", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_gzip, teardown_coding_test);
-       g_test_add ("/coding/request/gzip/with-junk", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_gzip_with_junk, teardown_coding_test);
-       g_test_add ("/coding/request/gzip/bad-server", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_gzip_bad_server, teardown_coding_test);
-       g_test_add ("/coding/request/deflate", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_deflate, teardown_coding_test);
-       g_test_add ("/coding/request/deflate/with-junk", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_deflate_with_junk, teardown_coding_test);
-       g_test_add ("/coding/request/deflate/bad-server", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_deflate_bad_server, teardown_coding_test);
-       g_test_add ("/coding/request/deflate-raw", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_deflate_raw, teardown_coding_test);
-       g_test_add ("/coding/request/deflate-raw/bad-server", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API),
-                   setup_coding_test, do_coding_req_test_deflate_raw_bad_server, teardown_coding_test);
-
        g_test_add ("/coding/message/empty", CodingTestData,
                    GINT_TO_POINTER (CODING_TEST_EMPTY),
                    setup_coding_test, do_coding_msg_empty_test, teardown_coding_test);
-       g_test_add ("/coding/request/empty", CodingTestData,
-                   GINT_TO_POINTER (CODING_TEST_REQUEST_API | CODING_TEST_EMPTY),
-                   setup_coding_test, do_coding_req_empty_test, teardown_coding_test);
 
        ret = g_test_run ();
 
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 92d02450..1546f1e3 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -314,91 +314,6 @@ do_timeout_test_for_session (SoupSession *session)
                g_object_unref (sockets[i]);
 }
 
-static void
-do_timeout_req_test_for_session (SoupSession *session)
-{
-       SoupRequest *req;
-       SoupMessage *msg;
-       GInputStream *stream;
-       SoupSocket *sockets[4] = { NULL, NULL, NULL, NULL };
-       SoupURI *timeout_uri;
-       GError *error = NULL;
-       int i;
-
-       g_signal_connect (session, "request-queued",
-                         G_CALLBACK (request_queued_socket_collector),
-                         &sockets);
-
-       debug_printf (1, "    First request\n");
-       timeout_uri = soup_uri_new_with_base (base_uri, "/timeout-persistent");
-       req = soup_session_request_uri (session, timeout_uri, NULL);
-       soup_uri_free (timeout_uri);
-
-       stream = soup_test_request_send (req, NULL, 0, &error);
-       if (error) {
-               g_assert_no_error (error);
-               g_clear_error (&error);
-       } else {
-               soup_test_request_read_all (req, stream, NULL, &error);
-               if (error) {
-                       g_assert_no_error (error);
-                       g_clear_error (&error);
-               }
-
-               soup_test_request_close_stream (req, stream, NULL, &error);
-               if (error) {
-                       g_assert_no_error (error);
-                       g_clear_error (&error);
-               }
-               g_object_unref (stream);
-       }
-
-       if (sockets[1]) {
-               soup_test_assert (sockets[1] == NULL, "Message was retried");
-               sockets[1] = sockets[2] = sockets[3] = NULL;
-       }
-       g_object_unref (req);
-
-       /* The server will grab server_mutex before returning the response,
-        * and release it when it's ready for us to send the second request.
-        */
-       g_mutex_lock (&server_mutex);
-       g_mutex_unlock (&server_mutex);
-
-       debug_printf (1, "    Second request\n");
-       req = soup_session_request_uri (session, base_uri, NULL);
-
-       stream = soup_test_request_send (req, NULL, 0, &error);
-       if (error) {
-               g_assert_no_error (error);
-               g_clear_error (&error);
-       } else {
-               soup_test_request_close_stream (req, stream, NULL, &error);
-               if (error) {
-                       g_assert_no_error (error);
-                       g_clear_error (&error);
-               }
-               g_object_unref (stream);
-       }
-
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
-       soup_test_assert_message_status (msg, SOUP_STATUS_OK);
-
-       soup_test_assert (sockets[1] == sockets[0],
-                         "Message was not retried on existing connection");
-       soup_test_assert (sockets[2] != NULL,
-                         "Message was not retried after disconnect");
-       soup_test_assert (sockets[2] != sockets[1],
-                         "Message was retried on closed connection");
-       soup_test_assert (sockets[3] == NULL,
-                         "Message was retried again");
-       g_object_unref (msg);
-       g_object_unref (req);
-
-       for (i = 0; sockets[i]; i++)
-               g_object_unref (sockets[i]);
-}
-
 static void
 do_persistent_connection_timeout_test (void)
 {
@@ -410,12 +325,6 @@ do_persistent_connection_timeout_test (void)
        session = soup_test_session_new (SOUP_TYPE_SESSION, NULL);
        do_timeout_test_for_session (session);
        soup_test_session_abort_unref (session);
-
-       debug_printf (1, "  Normal session, request API\n");
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        NULL);
-       do_timeout_req_test_for_session (session);
-       soup_test_session_abort_unref (session);
 }
 
 static void
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 042e63ba..7dde71be 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -254,94 +254,6 @@ do_callback_unref_test (void)
        /* Otherwise, if we haven't crashed, we're ok. */
 }
 
-static void
-cur_one_completed (GObject *source, GAsyncResult *result, gpointer session)
-{
-       SoupRequest *one = SOUP_REQUEST (source);
-       GError *error = NULL;
-
-       debug_printf (2, "  Request 1 completed\n");
-       soup_request_send_finish (one, result, &error);
-       g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED);
-       g_clear_error (&error);
-
-       g_object_unref (session);
-}
-
-static gboolean
-cur_idle_quit (gpointer loop)
-{
-       g_main_loop_quit (loop);
-       return FALSE;
-}
-
-static void
-cur_two_completed (GObject *source, GAsyncResult *result, gpointer loop)
-{
-       SoupRequest *two = SOUP_REQUEST (source);
-       GError *error = NULL;
-
-       debug_printf (2, "  Request 2 completed\n");
-       soup_request_send_finish (two, result, &error);
-       g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED);
-       g_clear_error (&error);
-
-       g_idle_add (cur_idle_quit, loop); 
-}
-
-static void
-do_callback_unref_req_test (void)
-{
-       SoupServer *bad_server;
-       SoupSession *session;
-       SoupRequest *one, *two;
-       GMainLoop *loop;
-       SoupURI *bad_uri;
-
-       /* Get a guaranteed-bad URI */
-       bad_server = soup_test_server_new (SOUP_TEST_SERVER_DEFAULT);
-       bad_uri = soup_test_server_get_uri (bad_server, "http", NULL);
-       soup_test_server_quit_unref (bad_server);
-
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        NULL);
-       g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
-
-       loop = g_main_loop_new (NULL, TRUE);
-
-       one = soup_session_request_uri (session, bad_uri, NULL);
-       g_object_add_weak_pointer (G_OBJECT (one), (gpointer *)&one);
-       two = soup_session_request_uri (session, bad_uri, NULL);
-       g_object_add_weak_pointer (G_OBJECT (two), (gpointer *)&two);
-       soup_uri_free (bad_uri);
-
-       soup_request_send_async (one, NULL, cur_one_completed, session);
-       g_object_unref (one);
-       soup_request_send_async (two, NULL, cur_two_completed, loop);
-       g_object_unref (two);
-
-       g_main_loop_run (loop);
-       g_main_loop_unref (loop);
-
-       g_assert_null (session);
-       if (session) {
-               g_object_remove_weak_pointer (G_OBJECT (session), (gpointer *)&session);
-               g_object_unref (session);
-       }
-       g_assert_null (one);
-       if (one) {
-               g_object_remove_weak_pointer (G_OBJECT (one), (gpointer *)&one);
-               g_object_unref (one);
-       }
-       g_assert_null (two);
-       if (two) {
-               g_object_remove_weak_pointer (G_OBJECT (two), (gpointer *)&two);
-               g_object_unref (two);
-       }
-
-       /* Otherwise, if we haven't crashed, we're ok. */
-}
-
 /* SoupSession should clean up all signal handlers on a message after
  * it is finished, allowing the message to be reused if desired.
  */
@@ -524,118 +436,6 @@ do_early_abort_test (void)
        soup_test_session_abort_unref (session);
 }
 
-static void
-ear_one_completed (GObject *source, GAsyncResult *result, gpointer user_data)
-{
-       GError *error = NULL;
-
-       debug_printf (2, "  Request 1 completed\n");
-       soup_request_send_finish (SOUP_REQUEST (source), result, &error);
-       g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
-       g_clear_error (&error);
-}
-
-static void
-ear_two_completed (GObject *source, GAsyncResult *result, gpointer loop)
-{
-       GError *error = NULL;
-
-       debug_printf (2, "  Request 2 completed\n");
-       soup_request_send_finish (SOUP_REQUEST (source), result, &error);
-       g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
-       g_clear_error (&error);
-
-       g_main_loop_quit (loop);
-}
-
-static void
-ear_three_completed (GObject *source, GAsyncResult *result, gpointer loop)
-{
-       GError *error = NULL;
-
-       debug_printf (2, "  Request 3 completed\n");
-       soup_request_send_finish (SOUP_REQUEST (source), result, &error);
-       g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
-       g_clear_error (&error);
-
-       g_main_loop_quit (loop);
-}
-
-static void
-ear_message_starting (SoupMessage *msg, gpointer cancellable)
-{
-       g_cancellable_cancel (cancellable);
-}
-
-static void
-ear_request_queued (SoupSession *session, SoupMessage *msg,
-                   gpointer cancellable)
-{
-       g_signal_connect (msg, "starting",
-                         G_CALLBACK (ear_message_starting),
-                         cancellable);
-}
-
-static void
-do_early_abort_req_test (void)
-{
-       SoupSession *session;
-       SoupRequest *req;
-       GMainContext *context;
-       GMainLoop *loop;
-       GCancellable *cancellable;
-
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        NULL);
-       req = soup_session_request_uri (session, base_uri, NULL);
-
-       context = g_main_context_default ();
-       loop = g_main_loop_new (context, TRUE);
-       soup_request_send_async (req, NULL, ear_one_completed, NULL);
-       g_object_unref (req);
-       g_main_context_iteration (context, FALSE);
-
-       soup_session_abort (session);
-       while (g_main_context_pending (context))
-               g_main_context_iteration (context, FALSE);
-       soup_test_session_abort_unref (session);
-
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        NULL);
-       req = soup_session_request_uri (session, base_uri, NULL);
-
-       g_signal_connect (soup_request_http_get_message (SOUP_REQUEST_HTTP (req)),
-                         "network-event",
-                         G_CALLBACK (ea_message_network_event),
-                         session);
-       soup_request_send_async (req, NULL, ear_two_completed, loop);
-       g_main_loop_run (loop);
-       g_object_unref (req);
-
-       while (g_main_context_pending (context))
-               g_main_context_iteration (context, FALSE);
-
-       soup_test_session_abort_unref (session);
-
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        NULL);
-       req = soup_session_request_uri (session, base_uri, NULL);
-
-       cancellable = g_cancellable_new ();
-       g_signal_connect (session, "request-queued",
-                         G_CALLBACK (ear_request_queued), cancellable);
-       soup_request_send_async (req, cancellable, ear_three_completed, loop);
-       g_main_loop_run (loop);
-       g_object_unref (req);
-       g_object_unref (cancellable);
-
-       while (g_main_context_pending (context))
-               g_main_context_iteration (context, FALSE);
-
-       soup_test_session_abort_unref (session);
-       g_main_loop_unref (loop);
-}
-
 static void
 do_one_accept_language_test (const char *language, const char *expected_header)
 {
@@ -743,21 +543,21 @@ static void
 do_cancel_while_reading_req_test_for_session (SoupSession *session,
                                              guint flags)
 {
-       SoupRequest *req;
+       SoupMessage *msg;
        SoupURI *uri;
        GCancellable *cancellable;
        GError *error = NULL;
 
        uri = soup_uri_new_with_base (base_uri, "/slow");
-       req = soup_session_request_uri (session, uri, NULL);
+       msg = soup_message_new_from_uri ("GET", uri);
        soup_uri_free (uri);
 
        cancellable = g_cancellable_new ();
-       soup_test_request_send (req, cancellable, flags, &error);
+       soup_test_request_send (session, msg, cancellable, flags, &error);
        g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
        g_clear_error (&error);
 
-       g_object_unref (req);
+       g_object_unref (msg);
        g_object_unref (cancellable);
 }
 
@@ -987,10 +787,8 @@ main (int argc, char **argv)
        g_test_add_func ("/misc/bigheader", do_host_big_header);
        g_test_add_func ("/misc/host", do_host_test);
        g_test_add_func ("/misc/callback-unref/msg", do_callback_unref_test);
-       g_test_add_func ("/misc/callback-unref/req", do_callback_unref_req_test);
        g_test_add_func ("/misc/msg-reuse", do_msg_reuse_test);
        g_test_add_func ("/misc/early-abort/msg", do_early_abort_test);
-       g_test_add_func ("/misc/early-abort/req", do_early_abort_req_test);
        g_test_add_func ("/misc/accept-language", do_accept_language_test);
        g_test_add_func ("/misc/cancel-while-reading/msg", do_cancel_while_reading_test);
        g_test_add_func ("/misc/cancel-while-reading/req/immediate", 
do_cancel_while_reading_immediate_req_test);
diff --git a/tests/multipart-test.c b/tests/multipart-test.c
index d9a00ae1..95b6efa3 100644
--- a/tests/multipart-test.c
+++ b/tests/multipart-test.c
@@ -28,6 +28,7 @@ char *base_uri_string;
 SoupURI *base_uri;
 SoupMultipartInputStream *multipart;
 unsigned passes;
+GMainLoop *loop;
 
 
 /* This payload contains 4 different responses.
@@ -127,7 +128,6 @@ got_headers (SoupMessage *msg, int *headers_count)
 static void
 read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
        GInputStream *stream = G_INPUT_STREAM (source);
        GError *error = NULL;
        gssize bytes_read;
@@ -150,18 +150,17 @@ read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data)
 
        g_input_stream_read_async (stream, buffer, READ_BUFFER_SIZE,
                                   G_PRIORITY_DEFAULT, NULL,
-                                  read_cb, data);
+                                  read_cb, NULL);
 }
 
 static void
 no_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
-       SoupRequest *request = SOUP_REQUEST (source);
+       SoupSession *session = SOUP_SESSION (source);
        GError *error = NULL;
        GInputStream* in;
 
-       in = soup_request_send_finish (request, res, &error);
+       in = soup_session_send_finish (session, res, &error);
        g_assert_no_error (error);
        if (error) {
                g_main_loop_quit (loop);
@@ -170,7 +169,7 @@ no_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data)
 
        g_input_stream_read_async (in, buffer, READ_BUFFER_SIZE,
                                   G_PRIORITY_DEFAULT, NULL,
-                                  read_cb, data);
+                                  read_cb, NULL);
 }
 
 static void
@@ -212,7 +211,6 @@ check_read (gsize nread, unsigned passes)
 static void
 multipart_read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
        GInputStream *in = G_INPUT_STREAM (source);
        GError *error = NULL;
        static gssize bytes_read_for_part = 0;
@@ -240,14 +238,14 @@ multipart_read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data)
                g_object_unref (in);
 
                soup_multipart_input_stream_next_part_async (multipart, G_PRIORITY_DEFAULT, NULL,
-                                                            multipart_next_part_cb, data);
+                                                            multipart_next_part_cb, NULL);
                return;
        }
 
        bytes_read_for_part += bytes_read;
        g_input_stream_read_async (in, buffer, READ_BUFFER_SIZE,
                                   G_PRIORITY_DEFAULT, NULL,
-                                  multipart_read_cb, data);
+                                  multipart_read_cb, NULL);
 }
 
 static void
@@ -302,7 +300,6 @@ check_headers (SoupMultipartInputStream* multipart, unsigned passes)
 static void
 multipart_next_part_cb (GObject *source, GAsyncResult *res, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
        GError *error = NULL;
        GInputStream *in;
        gsize read_size = READ_BUFFER_SIZE;
@@ -338,52 +335,46 @@ multipart_next_part_cb (GObject *source, GAsyncResult *res, gpointer data)
 static void
 multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
-       SoupRequest *request = SOUP_REQUEST (source);
+       SoupMessage *message = (SoupMessage*)data;
+       SoupSession *session = SOUP_SESSION (source);
        GError *error = NULL;
        GInputStream *in;
-       SoupMessage *message;
 
-       in = soup_request_send_finish (request, res, &error);
+       in = soup_session_send_finish (session, res, &error);
        g_assert_no_error (error);
        if (error) {
                g_main_loop_quit (loop);
                return;
        }
 
-       message = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
        multipart = soup_multipart_input_stream_new (message, in);
-       g_object_unref (message);
        g_object_unref (in);
 
-       if (g_object_get_data (source, "multipart-small-reads"))
+       if (g_object_get_data (G_OBJECT (message), "multipart-small-reads"))
                g_object_set_data (G_OBJECT (multipart), "multipart-small-reads", GINT_TO_POINTER(1));
 
        soup_multipart_input_stream_next_part_async (multipart, G_PRIORITY_DEFAULT, NULL,
-                                                    multipart_next_part_cb, data);
+                                                    multipart_next_part_cb, NULL);
 }
 
 static void
 sync_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data)
 {
-       GMainLoop *loop = (GMainLoop*)data;
-       SoupRequest *request = SOUP_REQUEST (source);
+       SoupMessage *message = (SoupMessage*)data;
+       SoupSession *session = SOUP_SESSION (source);
        GError *error = NULL;
        GInputStream *in;
-       SoupMessage *message;
        char buffer[READ_BUFFER_SIZE];
        gsize bytes_read;
 
-       in = soup_request_send_finish (request, res, &error);
+       in = soup_session_send_finish (session, res, &error);
        g_assert_no_error (error);
        if (error) {
                g_main_loop_quit (loop);
                return;
        }
 
-       message = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
        multipart = soup_multipart_input_stream_new (message, in);
-       g_object_unref (message);
        g_object_unref (in);
 
        while (TRUE) {
@@ -424,22 +415,14 @@ test_multipart (gconstpointer data)
 {
        int headers_expected = 1, sniffed_expected = 1;
        MultipartMode multipart_mode = GPOINTER_TO_INT (data);
-       SoupRequest* request;
        SoupMessage *msg;
-       GMainLoop *loop;
        int headers_count = 0;
        int sniffed_count = 0;
        GHashTable *params;
        const char *content_type;
        gboolean message_is_multipart = FALSE;
-       GError* error = NULL;
-
-       request = soup_session_request (session, base_uri_string, &error);
-       g_assert_no_error (error);
-       if (error)
-               return;
 
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
+       msg = soup_message_new ("GET", base_uri_string);
 
        /* This is used to track the number of parts. */
        passes = 0;
@@ -457,16 +440,18 @@ test_multipart (gconstpointer data)
        loop = g_main_loop_new (NULL, TRUE);
 
        if (multipart_mode == ASYNC_MULTIPART)
-               soup_request_send_async (request, NULL, multipart_handling_cb, loop);
+               soup_session_send_async (session, msg, 0, NULL, multipart_handling_cb, msg);
        else if (multipart_mode == ASYNC_MULTIPART_SMALL_READS) {
-               g_object_set_data (G_OBJECT (request), "multipart-small-reads", GINT_TO_POINTER(1));
-               soup_request_send_async (request, NULL, multipart_handling_cb, loop);
+               g_object_set_data (G_OBJECT (msg), "multipart-small-reads", GINT_TO_POINTER(1));
+               soup_session_send_async (session, msg, 0, NULL, multipart_handling_cb, msg);
        } else if (multipart_mode == SYNC_MULTIPART)
-               soup_request_send_async (request, NULL, sync_multipart_handling_cb, loop);
+               soup_session_send_async (session, msg, 0, NULL, sync_multipart_handling_cb, msg);
        else
-               soup_request_send_async (request, NULL, no_multipart_handling_cb, loop);
+               soup_session_send_async (session, msg, 0, NULL, no_multipart_handling_cb, NULL);
 
        g_main_loop_run (loop);
+       while (g_main_context_pending (NULL))
+               g_main_context_iteration (NULL, FALSE);
 
        content_type = soup_message_headers_get_content_type (msg->response_headers, &params);
 
@@ -482,8 +467,8 @@ test_multipart (gconstpointer data)
        g_assert_cmpint (sniffed_count, ==, sniffed_expected);
 
        g_object_unref (msg);
-       g_object_unref (request);
        g_main_loop_unref (loop);
+       loop = NULL;
 }
 
 int
diff --git a/tests/proxy-test.c b/tests/proxy-test.c
index 03c79377..1f5e646a 100644
--- a/tests/proxy-test.c
+++ b/tests/proxy-test.c
@@ -121,65 +121,6 @@ test_url (const char *url, int proxy, guint expected, gboolean close)
        soup_test_session_abort_unref (session);
 }
 
-static void
-test_url_new_api (const char *url, int proxy, guint expected, gboolean close)
-{
-       SoupSession *session;
-       SoupMessage *msg;
-       SoupRequest *request;
-       GInputStream *stream;
-       GError *error = NULL;
-       gboolean noproxy = !!strstr (url, "localhost");
-
-       /* FIXME g_test_skip() FIXME g_test_bug ("675865") */
-       if (!tls_available && g_str_has_prefix (url, "https:"))
-               return;
-
-       debug_printf (1, "  GET (request API) %s via %s%s\n", url, proxy_names[proxy],
-                     close ? " (with Connection: close)" : "");
-       if (proxy == UNAUTH_PROXY && expected != SOUP_STATUS_FORBIDDEN && !noproxy)
-               expected = SOUP_STATUS_PROXY_UNAUTHORIZED;
-
-       /* We create a new session for each request to ensure that
-        * connections/auth aren't cached between tests.
-        */
-       session = soup_test_session_new (SOUP_TYPE_SESSION,
-                                        SOUP_SESSION_PROXY_RESOLVER, proxy_resolvers[proxy],
-                                        SOUP_SESSION_SSL_STRICT, FALSE,
-                                        NULL);
-
-       g_signal_connect (session, "authenticate",
-                         G_CALLBACK (authenticate), NULL);
-
-       request = soup_session_request (session, url, NULL);
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
-
-       if (close) {
-               /* FIXME g_test_bug ("611663") */
-               g_signal_connect (msg, "starting",
-                                 G_CALLBACK (set_close_on_connect), NULL);
-       }
-
-       stream = soup_test_request_send (request, NULL, 0, &error);
-       g_assert_no_error (error);
-       g_clear_error (&error);
-
-       if (stream) {
-               soup_test_request_close_stream (request, stream, NULL, &error);
-               g_assert_no_error (error);
-               g_clear_error (&error);
-               g_object_unref (stream);
-       }
-
-       debug_printf (1, "  %d %s\n", msg->status_code, msg->reason_phrase);
-       soup_test_assert_message_status (msg, expected);
-
-       g_object_unref (msg);
-       g_object_unref (request);
-
-       soup_test_session_abort_unref (session);
-}
-
 static void
 do_proxy_test (SoupProxyTest *test)
 {
@@ -207,21 +148,14 @@ do_proxy_test (SoupProxyTest *test)
        }
 
        test_url (http_url, SIMPLE_PROXY, test->final_status, FALSE);
-       test_url_new_api (http_url, SIMPLE_PROXY, test->final_status, FALSE);
        test_url (https_url, SIMPLE_PROXY, test->final_status, FALSE);
-       test_url_new_api (https_url, SIMPLE_PROXY, test->final_status, FALSE);
 
        test_url (http_url, AUTH_PROXY, test->final_status, FALSE);
-       test_url_new_api (http_url, AUTH_PROXY, test->final_status, FALSE);
        test_url (https_url, AUTH_PROXY, test->final_status, FALSE);
-       test_url_new_api (https_url, AUTH_PROXY, test->final_status, FALSE);
        test_url (https_url, AUTH_PROXY, test->final_status, TRUE);
-       test_url_new_api (https_url, AUTH_PROXY, test->final_status, TRUE);
 
        test_url (http_url, UNAUTH_PROXY, test->final_status, FALSE);
-       test_url_new_api (http_url, UNAUTH_PROXY, test->final_status, FALSE);
        test_url (https_url, UNAUTH_PROXY, test->final_status, FALSE);
-       test_url_new_api (https_url, UNAUTH_PROXY, test->final_status, FALSE);
 
        g_free (http_url);
        g_free (https_url);
@@ -311,15 +245,13 @@ do_proxy_redirect_test (void)
 static void
 do_proxy_auth_request (const char *url, SoupSession *session, gboolean do_read)
 {
-       SoupRequest *request;
        SoupMessage *msg;
        GInputStream *stream;
        GError *error = NULL;
 
-       request = soup_session_request (session, url, NULL);
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (request));
+       msg = soup_message_new ("GET", url);
 
-       stream = soup_test_request_send (request, NULL, 0, &error);
+       stream = soup_test_request_send (session, msg, NULL, 0, &error);
        g_assert_no_error (error);
        g_clear_error (&error);
 
@@ -335,7 +267,7 @@ do_proxy_auth_request (const char *url, SoupSession *session, gboolean do_read)
                } while (nread > 0);
        }
 
-       soup_test_request_close_stream (request, stream, NULL, &error);
+       soup_test_request_close_stream (stream, NULL, &error);
        g_assert_no_error (error);
        g_clear_error (&error);
        g_object_unref (stream);
@@ -344,7 +276,6 @@ do_proxy_auth_request (const char *url, SoupSession *session, gboolean do_read)
        soup_test_assert_message_status (msg, SOUP_STATUS_OK);
 
        g_object_unref (msg);
-       g_object_unref (request);
 }
 
 static void
diff --git a/tests/redirect-test.c b/tests/redirect-test.c
index 9ecc2e2d..2c73b800 100644
--- a/tests/redirect-test.c
+++ b/tests/redirect-test.c
@@ -194,98 +194,12 @@ do_message_api_test (SoupSession *session, TestCase *test)
        g_object_unref (msg);
 }
 
-static void
-do_request_api_test (SoupSession *session, TestCase *test)
-{
-       SoupURI *uri;
-       SoupRequestHTTP *reqh;
-       SoupMessage *msg;
-       TestRequest *treq;
-       GInputStream *stream;
-       GError *error = NULL;
-
-       if (test->bugref)
-               g_test_bug (test->bugref);
-
-       uri = soup_uri_new_with_base (base_uri, test->requests[0].path);
-       reqh = soup_session_request_http_uri (session,
-                                             test->requests[0].method,
-                                             uri, &error);
-       soup_uri_free (uri);
-       g_assert_no_error (error);
-       if (error) {
-               g_error_free (error);
-               return;
-       }
-
-       msg = soup_request_http_get_message (reqh);
-       if (msg->method == SOUP_METHOD_POST) {
-               GBytes *request_body;
-
-               request_body = g_bytes_new_static ("post body", strlen ("post body"));
-               soup_message_set_request_body_from_bytes (msg, "text/plain", request_body);
-               g_bytes_unref (request_body);
-       }
-
-       treq = &test->requests[0];
-       g_signal_connect (msg, "got_headers",
-                         G_CALLBACK (got_headers), &treq);
-       g_signal_connect (msg, "restarted",
-                         G_CALLBACK (restarted), &treq);
-
-       stream = soup_test_request_send (SOUP_REQUEST (reqh), NULL, 0, &error);
-
-       if (SOUP_STATUS_IS_TRANSPORT_ERROR (test->final_status) &&
-           test->final_status != SOUP_STATUS_MALFORMED) {
-               g_assert_error (error, SOUP_HTTP_ERROR, test->final_status);
-               g_clear_error (&error);
-
-               g_assert_null (stream);
-               g_clear_object (&stream);
-
-               g_object_unref (msg);
-               g_object_unref (reqh);
-               return;
-       }
-
-       g_assert_no_error (error);
-       if (error) {
-               g_error_free (error);
-               g_object_unref (msg);
-               g_object_unref (reqh);
-               return;
-       }
-
-       soup_test_request_read_all (SOUP_REQUEST (reqh), stream, NULL, &error);
-       g_assert_no_error (error);
-       g_clear_error (&error);
-
-       soup_test_request_close_stream (SOUP_REQUEST (reqh), stream, NULL, &error);
-       g_assert_no_error (error);
-       g_clear_error (&error);
-       g_object_unref (stream);
-
-       if (test->final_status == SOUP_STATUS_MALFORMED)
-               g_assert_cmpint (msg->status_code, ==, test->requests[0].status_code);
-       else
-               g_assert_cmpint (msg->status_code, ==, test->final_status);
-
-       g_object_unref (msg);
-       g_object_unref (reqh);
-}
-
 static void
 do_async_msg_api_test (gconstpointer test)
 {
        do_message_api_test (async_session, (TestCase *)test);
 }
 
-static void
-do_async_req_api_test (gconstpointer test)
-{
-       do_request_api_test (async_session, (TestCase *)test);
-}
-
 static void
 server_callback (SoupServer        *server,
                 SoupServerMessage *msg,
@@ -430,12 +344,6 @@ main (int argc, char **argv)
                                        tests[n].requests[0].status_code);
                g_test_add_data_func (path, &tests[n], do_async_msg_api_test);
                g_free (path);
-
-               path = g_strdup_printf ("/redirect/req/%d-%s-%d", n,
-                                       tests[n].requests[0].method,
-                                       tests[n].requests[0].status_code);
-               g_test_add_data_func (path, &tests[n], do_async_req_api_test);
-               g_free (path);
        }
 
        ret = g_test_run ();
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index e81811b0..19fc850d 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -352,10 +352,8 @@ test_sniffing (const char *path, const char *expected_type)
        SoupURI *uri;
        SoupMessage *msg;
        GBytes *body;
-       SoupRequest *req;
-       GInputStream *stream;
        char *sniffed_type = NULL;
-       const char *req_sniffed_type;
+       char *uri_string;
        GError *error = NULL;
 
        uri = soup_uri_new_with_base (base_uri, path);
@@ -370,18 +368,14 @@ test_sniffing (const char *path, const char *expected_type)
        g_bytes_unref (body);
        g_object_unref (msg);
 
-       req = soup_session_request_uri (session, uri, NULL);
-       stream = soup_test_request_send (req, NULL, 0, &error);
-       if (stream) {
-               soup_test_request_close_stream (req, stream, NULL, &error);
-               g_object_unref (stream);
-       }
+       sniffed_type = NULL;
+       uri_string = soup_uri_to_string (uri, FALSE);
+       body = soup_session_load_uri_bytes (session, uri_string, NULL, &sniffed_type, &error);
        g_assert_no_error (error);
-       g_clear_error (&error);
-
-       req_sniffed_type = soup_request_get_content_type (req);
-       g_assert_cmpstr (req_sniffed_type, ==, expected_type);
-       g_object_unref (req);
+       g_assert_cmpstr (sniffed_type, ==, expected_type);
+       g_free (sniffed_type);
+       g_free (uri_string);
+       g_bytes_unref (body);
 
        soup_uri_free (uri);
 }
@@ -406,11 +400,7 @@ test_disabled (gconstpointer data)
        SoupURI *uri;
        SoupMessage *msg;
        GBytes *body;
-       SoupRequest *req;
-       GInputStream *stream;
        char *sniffed_type = NULL;
-       const char *sniffed_content_type;
-       GError *error = NULL;
 
        g_test_bug ("574773");
 
@@ -429,25 +419,6 @@ test_disabled (gconstpointer data)
        g_assert_null (sniffed_type);
        g_bytes_unref (body);
        g_object_unref (msg);
-
-       req = soup_session_request_uri (session, uri, NULL);
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
-       g_assert_false (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
-       soup_message_disable_feature (msg, SOUP_TYPE_CONTENT_SNIFFER);
-       g_assert_true (soup_message_is_feature_disabled (msg, SOUP_TYPE_CONTENT_SNIFFER));
-       g_object_unref (msg);
-       stream = soup_test_request_send (req, NULL, 0, &error);
-       if (stream) {
-               soup_test_request_close_stream (req, stream, NULL, &error);
-               g_object_unref (stream);
-       }
-       g_assert_no_error (error);
-
-       sniffed_content_type = soup_request_get_content_type (req);
-       g_assert_cmpstr (sniffed_content_type, ==, NULL);
-
-       g_object_unref (req);
-
        soup_uri_free (uri);
 }
 
diff --git a/tests/test-utils.c b/tests/test-utils.c
index eefefec7..9e07be0b 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -650,13 +650,15 @@ async_as_sync_callback (GObject      *object,
 }
 
 typedef struct {
-       SoupRequest  *req;
+       SoupSession *session;
+       SoupMessage  *msg;
        GCancellable *cancellable;
        SoupTestRequestFlags flags;
 } CancelData;
 
 static CancelData *
-create_cancel_data (SoupRequest          *req,
+create_cancel_data (SoupSession          *session,
+                   SoupMessage          *msg,
                    GCancellable         *cancellable,
                    SoupTestRequestFlags  flags)
 {
@@ -667,9 +669,10 @@ create_cancel_data (SoupRequest          *req,
 
        cancel_data = g_slice_new0 (CancelData);
        cancel_data->flags = flags;
-       if (flags & SOUP_TEST_REQUEST_CANCEL_MESSAGE && SOUP_IS_REQUEST_HTTP (req))
-               cancel_data->req = g_object_ref (req);
-       else if (flags & SOUP_TEST_REQUEST_CANCEL_CANCELLABLE)
+       if (flags & SOUP_TEST_REQUEST_CANCEL_MESSAGE) {
+               cancel_data->session = session;
+               cancel_data->msg = g_object_ref (msg);
+       } else if (flags & SOUP_TEST_REQUEST_CANCEL_CANCELLABLE)
                cancel_data->cancellable = g_object_ref (cancellable);
        return cancel_data;
 }
@@ -678,12 +681,11 @@ inline static void
 cancel_message_or_cancellable (CancelData *cancel_data)
 {
        if (cancel_data->flags & SOUP_TEST_REQUEST_CANCEL_MESSAGE) {
-               SoupRequest *req = cancel_data->req;
-               SoupMessage *msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
-               soup_session_cancel_message (soup_request_get_session (req), msg,
+               SoupMessage *msg = cancel_data->msg;
+
+               soup_session_cancel_message (cancel_data->session, msg,
                                             SOUP_STATUS_CANCELLED);
                g_object_unref (msg);
-               g_object_unref (req);
        } else if (cancel_data->flags & SOUP_TEST_REQUEST_CANCEL_CANCELLABLE) {
                g_cancellable_cancel (cancel_data->cancellable);
                g_object_unref (cancel_data->cancellable);
@@ -699,14 +701,15 @@ cancel_request_timeout (gpointer data)
 }
 
 GInputStream *
-soup_test_request_send (SoupRequest   *req,
+soup_test_request_send (SoupSession   *session,
+                       SoupMessage   *msg,
                        GCancellable  *cancellable,
                        guint          flags,
                        GError       **error)
 {
        AsyncAsSyncData data;
        GInputStream *stream;
-       CancelData *cancel_data = create_cancel_data (req, cancellable, flags);
+       CancelData *cancel_data = create_cancel_data (session, msg, cancellable, flags);
 
        data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
        if (cancel_data &&
@@ -716,10 +719,11 @@ soup_test_request_send (SoupRequest   *req,
        }
        if (cancel_data && (flags & SOUP_TEST_REQUEST_CANCEL_PREEMPTIVE))
                cancel_message_or_cancellable (cancel_data);
-       soup_request_send_async (req, cancellable, async_as_sync_callback, &data);
+       soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, cancellable,
+                                async_as_sync_callback, &data);
        g_main_loop_run (data.loop);
 
-       stream = soup_request_send_finish (req, data.result, error);
+       stream = soup_session_send_finish (session, data.result, error);
 
        if (cancel_data && (flags &  SOUP_TEST_REQUEST_CANCEL_AFTER_SEND_FINISH)) {
                GMainContext *context;
@@ -738,8 +742,7 @@ soup_test_request_send (SoupRequest   *req,
 }
 
 gboolean
-soup_test_request_read_all (SoupRequest   *req,
-                           GInputStream  *stream,
+soup_test_request_read_all (GInputStream  *stream,
                            GCancellable  *cancellable,
                            GError       **error)
 {
@@ -751,8 +754,8 @@ soup_test_request_read_all (SoupRequest   *req,
 
        do {
                 g_input_stream_read_async (stream, buf, sizeof (buf),
-                                                G_PRIORITY_DEFAULT, cancellable,
-                                                async_as_sync_callback, &data);
+                                          G_PRIORITY_DEFAULT, cancellable,
+                                          async_as_sync_callback, &data);
                 g_main_loop_run (data.loop);
                 nread = g_input_stream_read_finish (stream, data.result, error);
                 g_object_unref (data.result);
@@ -764,8 +767,7 @@ soup_test_request_read_all (SoupRequest   *req,
 }
 
 gboolean
-soup_test_request_close_stream (SoupRequest   *req,
-                               GInputStream  *stream,
+soup_test_request_close_stream (GInputStream  *stream,
                                GCancellable  *cancellable,
                                GError       **error)
 {
diff --git a/tests/test-utils.h b/tests/test-utils.h
index 64ac71ad..496f99a6 100644
--- a/tests/test-utils.h
+++ b/tests/test-utils.h
@@ -70,16 +70,15 @@ SoupURI     *soup_test_server_get_uri        (SoupServer            *server,
                                              const char            *host);
 void         soup_test_server_quit_unref     (SoupServer            *server);
 
-GInputStream *soup_test_request_send         (SoupRequest  *req,
+GInputStream *soup_test_request_send         (SoupSession  *session,
+                                             SoupMessage  *msg,
                                              GCancellable *cancellable,
                                              guint         flags,
                                              GError       **error);
-gboolean      soup_test_request_read_all     (SoupRequest   *req,
-                                             GInputStream  *stream,
+gboolean      soup_test_request_read_all     (GInputStream  *stream,
                                              GCancellable  *cancellable,
                                              GError       **error);
-gboolean      soup_test_request_close_stream (SoupRequest   *req,
-                                             GInputStream  *stream,
+gboolean      soup_test_request_close_stream (GInputStream  *stream,
                                              GCancellable  *cancellable,
                                              GError       **error);
 GBytes       *soup_test_session_send         (SoupSession   *session,
diff --git a/tests/timeout-test.c b/tests/timeout-test.c
index b3325e42..0d773a4f 100644
--- a/tests/timeout-test.c
+++ b/tests/timeout-test.c
@@ -103,104 +103,6 @@ do_msg_tests_for_session (SoupSession *timeout_session,
        }
 }
 
-static void
-do_request_to_session (SoupSession *session, SoupURI *uri,
-                      const char *comment, gboolean expect_timeout)
-{
-       SoupRequest *req;
-       SoupMessage *msg;
-       GInputStream *stream;
-       GError *error = NULL;
-       gboolean finished = FALSE;
-
-       debug_printf (1, "    req %s\n", comment);
-       req = soup_session_request_uri (session, uri, NULL);
-       msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
-
-       g_signal_connect (msg, "finished",
-                         G_CALLBACK (message_finished), &finished);
-       stream = soup_test_request_send (req, NULL, 0, &error);
-
-       if (expect_timeout)
-               g_assert_error (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT);
-       else
-               g_assert_no_error (error);
-       g_clear_error (&error);
-
-       if (stream) {
-               soup_test_request_read_all (req, stream, NULL, &error);
-               g_assert_no_error (error);
-       }
-
-       if (stream) {
-               soup_test_request_close_stream (req, stream, NULL, &error);
-               g_assert_no_error (error);
-               g_object_unref (stream);
-       }
-
-       if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
-               g_assert_true (soup_message_is_keepalive (msg));
-       g_assert_true (finished);
-
-       g_signal_handlers_disconnect_by_func (msg,
-                                             G_CALLBACK (message_finished),
-                                             &finished);
-       g_object_unref (msg);
-       g_object_unref (req);
-}
-
-static void
-do_req_tests_for_session (SoupSession *timeout_session,
-                         SoupSession *idle_session,
-                         SoupSession *plain_session,
-                         SoupURI *fast_uri,
-                         SoupURI *slow_uri)
-{
-       SoupSocket *ret, *idle_first = NULL, *idle_second;
-       SoupSocket *plain_first = NULL, *plain_second;
-
-       if (idle_session) {
-               g_signal_connect (idle_session, "request-started",
-                                 G_CALLBACK (request_started_cb), &ret);
-               do_request_to_session (idle_session, fast_uri, "fast to idle", FALSE);
-               idle_first = g_object_ref (ret);
-       }
-
-       if (plain_session) {
-               g_signal_connect (plain_session, "request-started",
-                                 G_CALLBACK (request_started_cb), &ret);
-               do_request_to_session (plain_session, fast_uri, "fast to plain", FALSE);
-               plain_first = g_object_ref (ret);
-       }
-
-       do_request_to_session (timeout_session, fast_uri, "fast to timeout", FALSE);
-       do_request_to_session (timeout_session, slow_uri, "slow to timeout", TRUE);
-
-       if (idle_session) {
-               do_request_to_session (idle_session, fast_uri, "fast to idle", FALSE);
-               idle_second = ret;
-               g_signal_handlers_disconnect_by_func (idle_session,
-                                                     (gpointer)request_started_cb,
-                                                     &ret);
-
-               soup_test_assert (idle_first != idle_second,
-                                 "idle_session did not close first connection");
-               g_object_unref (idle_first);
-       }
-
-       if (plain_session) {
-               do_request_to_session (plain_session, fast_uri, "fast to plain", FALSE);
-               plain_second = ret;
-               g_signal_handlers_disconnect_by_func (plain_session,
-                                                     (gpointer)request_started_cb,
-                                                     &ret);
-
-               soup_test_assert (plain_first == plain_second,
-                                 "plain_session closed connection");
-               g_object_unref (plain_first);
-       }
-}
-
 static void
 do_async_timeout_tests (gconstpointer data)
 {
@@ -235,8 +137,6 @@ do_async_timeout_tests (gconstpointer data)
 
        do_msg_tests_for_session (timeout_session, idle_session, plain_session,
                                  fast_uri, slow_uri);
-       do_req_tests_for_session (timeout_session, idle_session, plain_session,
-                                 fast_uri, slow_uri);
        soup_test_session_abort_unref (timeout_session);
        soup_test_session_abort_unref (idle_session);
        soup_test_session_abort_unref (plain_session);
@@ -269,7 +169,6 @@ do_sync_timeout_tests (gconstpointer data)
        plain_session = soup_test_session_new (SOUP_TYPE_SESSION,
                                               NULL);
        do_msg_tests_for_session (timeout_session, NULL, plain_session, fast_uri, slow_uri);
-       do_req_tests_for_session (timeout_session, NULL, plain_session, fast_uri, slow_uri);
        soup_test_session_abort_unref (timeout_session);
        soup_test_session_abort_unref (plain_session);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]