[libsoup] SoupMessage: add soup_message_get_soup_request()



commit 76883f68eaed736caa298a0177da9fbcef5f31e3
Author: Dan Winship <danw gnome org>
Date:   Wed Jul 25 08:44:02 2012 -0400

    SoupMessage: add soup_message_get_soup_request()
    
    When dealing with SoupMessage-related signals in SoupRequest-using
    code, it's useful to be able to get the message's associated
    SoupRequest.

 docs/reference/libsoup-2.4-sections.txt |    1 +
 libsoup/libsoup-2.4.sym                 |    1 +
 libsoup/soup-message-private.h          |    5 ++++
 libsoup/soup-message.c                  |   32 +++++++++++++++++++++++++++++++
 libsoup/soup-message.h                  |    3 ++
 libsoup/soup-request-http.c             |    3 ++
 6 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index b46c9f9..52cdc37 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -35,6 +35,7 @@ SoupChunkAllocator
 soup_message_set_chunk_allocator
 <SUBSECTION>
 soup_message_disable_feature
+soup_message_get_soup_request
 <SUBSECTION>
 SOUP_MESSAGE_METHOD
 SOUP_MESSAGE_URI
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 9a1c7df..63fda17 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -226,6 +226,7 @@ soup_message_get_first_party
 soup_message_get_flags
 soup_message_get_https_status
 soup_message_get_http_version
+soup_message_get_soup_request
 soup_message_get_type
 soup_message_get_uri
 soup_message_got_body
diff --git a/libsoup/soup-message-private.h b/libsoup/soup-message-private.h
index f688515..53f8e81 100644
--- a/libsoup/soup-message-private.h
+++ b/libsoup/soup-message-private.h
@@ -38,6 +38,8 @@ typedef struct {
 
 	GTlsCertificate      *tls_certificate;
 	GTlsCertificateFlags  tls_errors;
+
+	SoupRequest       *request;
 } SoupMessagePrivate;
 #define SOUP_MESSAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_MESSAGE, SoupMessagePrivate))
 
@@ -133,4 +135,7 @@ GInputStream *soup_message_setup_body_istream (GInputStream *body_stream,
 					       SoupSession *session,
 					       SoupProcessingStage start_at_stage);
 
+void soup_message_set_soup_request (SoupMessage *msg,
+				    SoupRequest *req);
+
 #endif /* SOUP_MESSAGE_PRIVATE_H */
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 445cdff..7a1d0b7 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -1995,3 +1995,35 @@ soup_message_set_redirect (SoupMessage *msg, guint status_code,
 	g_free (location_str);
 	soup_uri_free (location);
 }
+
+void
+soup_message_set_soup_request (SoupMessage *msg,
+			       SoupRequest *req)
+{
+	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
+
+	priv->request = req;
+}
+
+/**
+ * soup_message_get_soup_request:
+ * @msg: a #SoupMessage
+ *
+ * If @msg is associated with a #SoupRequest, this returns that
+ * request. Otherwise it returns %NULL.
+ *
+ * Return value: @msg's associated #SoupRequest
+ *
+ * Since: 2.40
+ */
+SoupRequest *
+soup_message_get_soup_request (SoupMessage *msg)
+{
+	SoupMessagePrivate *priv;
+
+	g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL);
+
+	priv = SOUP_MESSAGE_GET_PRIVATE (msg);
+	return priv->request;
+}
+
diff --git a/libsoup/soup-message.h b/libsoup/soup-message.h
index 676de66..6692c38 100644
--- a/libsoup/soup-message.h
+++ b/libsoup/soup-message.h
@@ -180,6 +180,9 @@ SOUP_AVAILABLE_IN_2_28
 void           soup_message_disable_feature     (SoupMessage       *msg,
 						 GType              feature_type);
 
+SOUP_AVAILABLE_IN_2_42
+SoupRequest   *soup_message_get_soup_request    (SoupMessage       *msg);
+
 void soup_message_wrote_informational (SoupMessage *msg);
 void soup_message_wrote_headers       (SoupMessage *msg);
 void soup_message_wrote_chunk         (SoupMessage *msg);
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 01c37e3..fe1a974 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -30,6 +30,7 @@
 #include "soup-request-http.h"
 #include "soup.h"
 #include "soup-cache-private.h"
+#include "soup-message-private.h"
 #include "soup-session-private.h"
 
 G_DEFINE_TYPE (SoupRequestHTTP, soup_request_http, SOUP_TYPE_REQUEST)
@@ -201,6 +202,8 @@ soup_request_http_check_uri (SoupRequest  *request,
 		return FALSE;
 
 	http->priv->msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
+	soup_message_set_soup_request (http->priv->msg, request);
+
 	g_signal_connect (http->priv->msg, "content-sniffed",
 			  G_CALLBACK (content_sniffed), http);
 



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