[libsoup] SoupMessage: Add SOUP_MESSAGE_IDEMPOTENT flag



commit 0d51bcfe06177025e235f860c75275744337739c
Author: Milan Crha <mcrha redhat com>
Date:   Mon Aug 13 14:27:02 2012 +0200

    SoupMessage: Add SOUP_MESSAGE_IDEMPOTENT flag
    
    In particular, this lets the app indicate that it's OK to use an
    existing connection when sending a POST.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681493

 libsoup/soup-message.c |    7 ++++++-
 libsoup/soup-message.h |    3 ++-
 libsoup/soup-session.c |    3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 3e1112e..2271cd0 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -1453,7 +1453,12 @@ soup_message_cleanup_response (SoupMessage *req)
  * @SOUP_MESSAGE_NEW_CONNECTION: The message should be sent on a
  *   newly-created connection, not reusing an existing persistent
  *   connection. Note that messages with non-idempotent
- *   #SoupMessage:method<!-- -->s behave this way by default.
+ *   #SoupMessage:method<!-- -->s behave this way by default,
+ *   unless #SOUP_MESSAGE_IDEMPOTENT is set.
+ * @SOUP_MESSAGE_IDEMPOTENT: The message is considered idempotent,
+ *   regardless its #SoupMessage:method, and allows reuse of existing
+ *   idle connections, instead of always requiring a new one, unless
+ *   #SOUP_MESSAGE_NEW_CONNECTION is set.
  *
  * Various flags that can be set on a #SoupMessage to alter its
  * behavior.
diff --git a/libsoup/soup-message.h b/libsoup/soup-message.h
index d3c7e3c..d74ee13 100644
--- a/libsoup/soup-message.h
+++ b/libsoup/soup-message.h
@@ -119,7 +119,8 @@ typedef enum {
 #endif
 	SOUP_MESSAGE_CONTENT_DECODED      = (1 << 4),
 	SOUP_MESSAGE_CERTIFICATE_TRUSTED  = (1 << 5),
-	SOUP_MESSAGE_NEW_CONNECTION       = (1 << 6)
+	SOUP_MESSAGE_NEW_CONNECTION       = (1 << 6),
+	SOUP_MESSAGE_IDEMPOTENT           = (1 << 7)
 } SoupMessageFlags;
 
 void             soup_message_set_flags           (SoupMessage           *msg,
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 7b68d42..90e9189 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1207,7 +1207,8 @@ soup_session_get_connection (SoupSession *session,
 
 	need_new_connection =
 		(soup_message_get_flags (item->msg) & SOUP_MESSAGE_NEW_CONNECTION) ||
-		!SOUP_METHOD_IS_IDEMPOTENT (item->msg->method);
+		(!(soup_message_get_flags (item->msg) & SOUP_MESSAGE_IDEMPOTENT) &&
+		 !SOUP_METHOD_IS_IDEMPOTENT (item->msg->method));
 
 	g_mutex_lock (&priv->conn_lock);
 



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