soup-session: use SoupMessageQueueItem's cancellable for the GTask
authorSergio Villar Senin <svillar@igalia.com>
Wed, 30 Jan 2013 18:25:12 +0000 (19:25 +0100)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 4 Feb 2013 09:13:49 +0000 (10:13 +0100)
Even if the caller does not specify a GCancellable the GTask must use the
one that comes with the item by default.

This also sets check_cancellable() to FALSE in the session's GTask in order
not to override error messages previously set on the GTask in case of
cancellations.

https://bugzilla.gnome.org/show_bug.cgi?id=692310

libsoup/soup-session.c

index ab9e2cd..bc23e88 100644 (file)
@@ -3894,15 +3894,23 @@ soup_session_send_async (SoupSession         *session,
        g_signal_connect (msg, "finished",
                          G_CALLBACK (async_send_request_finished), item);
 
-       item->new_api = TRUE;
-       item->task = g_task_new (session, cancellable, callback, user_data);
-       g_task_set_task_data (item->task, item, (GDestroyNotify) soup_message_queue_item_unref);
-
        if (cancellable) {
                g_object_unref (item->cancellable);
                item->cancellable = g_object_ref (cancellable);
        }
 
+       item->new_api = TRUE;
+       item->task = g_task_new (session, item->cancellable, callback, user_data);
+       g_task_set_task_data (item->task, item, (GDestroyNotify) soup_message_queue_item_unref);
+
+       /* Do not check for cancellations as we do not want to
+        * overwrite custom error messages set during cancellations
+        * (for example SOUP_HTTP_ERROR is set for cancelled messages
+        * in async_send_request_return_result() (status_code==1
+        * means CANCEL and is considered a TRANSPORT_ERROR)).
+        */
+       g_task_set_check_cancellable (item->task, FALSE);
+
        if (async_respond_from_cache (session, item))
                item->state = SOUP_MESSAGE_CACHED;
        else