[libsoup] soup-session: fix up the SoupRequest requeuing logic



commit 08ff6d1d2124565b10c0b22b17769bf91fc6d5c2
Author: Dan Winship <danw gnome org>
Date:   Sat Jan 5 18:25:12 2013 -0500

    soup-session: fix up the SoupRequest requeuing logic
    
    Split the "this message is likely to be requeued" logic into a single
    function that the sync and async codepaths can share, and fix it to
    not think that SOUP_MESSAGE_NO_REDIRECT messages will be redirected,
    or that messages that disable SOUP_TYPE_AUTH_MANAGER will be
    authenticated.

 libsoup/soup-session.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 20e9232..ef8983f 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -3493,6 +3493,19 @@ soup_session_class_init (SoupSessionClass *session_class)
 }
 
 
+static gboolean
+expected_to_be_requeued (SoupSession *session, SoupMessage *msg)
+{
+	if (msg->status_code == SOUP_STATUS_UNAUTHORIZED ||
+	    msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED)
+		return !soup_message_disables_feature (msg, SOUP_TYPE_AUTH_MANAGER);
+
+	if (!(soup_message_get_flags (msg) & SOUP_MESSAGE_NO_REDIRECT))
+		return soup_session_would_redirect (session, msg);
+
+	return FALSE;
+}
+
 /* send_request_async */
 
 static void
@@ -3615,12 +3628,10 @@ static void
 send_async_maybe_complete (SoupMessageQueueItem *item,
 			   GInputStream         *stream)
 {
-	if (item->msg->status_code == SOUP_STATUS_UNAUTHORIZED ||
-	    item->msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED ||
-	    soup_session_would_redirect (item->session, item->msg)) {
+	if (expected_to_be_requeued (item->session, item->msg)) {
 		GOutputStream *ostream;
 
-		/* Message may be requeued, so gather the current message body... */
+		/* Gather the current message body... */
 		ostream = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
 		g_object_set_data_full (G_OBJECT (item->task), "SoupSession:ostream",
 					ostream, g_object_unref);
@@ -3927,10 +3938,7 @@ soup_session_send_request (SoupSession   *session,
 		if (!stream)
 			break;
 
-		/* Break if the message doesn't look likely-to-be-requeued */
-		if (msg->status_code != SOUP_STATUS_UNAUTHORIZED &&
-		    msg->status_code != SOUP_STATUS_PROXY_UNAUTHORIZED &&
-		    !soup_session_would_redirect (session, msg))
+		if (!expected_to_be_requeued (session, msg))
 			break;
 
 		/* Gather the current message body... */



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