[libsoup] Rename all remaining "SoupMessage *req"s to "msg"



commit 89dd1240a6077b18f6d6e4b119b403de38b73141
Author: Dan Winship <danw gnome org>
Date:   Thu Dec 13 16:07:57 2012 +0100

    Rename all remaining "SoupMessage *req"s to "msg"
    
    Originally (ie, 12 years ago last week) the HTTP message type in soup
    was called SoupRequest, and most SoupRequest variables were called
    "req". Shortly after, SoupRequest was renamed to SoupMessage, but none
    of the existing "req"s were renamed, and in fact, new ones kept
    getting added. Eventually, "msg" became the standard name for a
    SoupMessage variable, but a handful of "req"s have managed to survive
    to this day. With the increasing integration of the modern-day
    SoupRequest, this has gone from "inconsistent" to "confusing", so fix
    all the remaining stray "SoupMessage *req"s.

 libsoup/soup-message-client-io.c |   60 +++++++++++++++++++-------------------
 libsoup/soup-message-private.h   |    4 +-
 libsoup/soup-message.c           |   40 ++++++++++++------------
 libsoup/soup-server.c            |   28 +++++++++---------
 libsoup/soup-session-async.c     |   10 +++---
 5 files changed, 71 insertions(+), 71 deletions(-)
---
diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c
index 1ee4cbb..0d3df28 100644
--- a/libsoup/soup-message-client-io.c
+++ b/libsoup/soup-message-client-io.c
@@ -20,45 +20,45 @@
 #include "soup-misc-private.h"
 
 static guint
-parse_response_headers (SoupMessage *req,
+parse_response_headers (SoupMessage *msg,
 			char *headers, guint headers_len,
 			SoupEncoding *encoding,
 			gpointer user_data,
 			GError **error)
 {
-	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req);
+	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
 	SoupHTTPVersion version;
 
-	g_free(req->reason_phrase);
-	req->reason_phrase = NULL;
+	g_free(msg->reason_phrase);
+	msg->reason_phrase = NULL;
 	if (!soup_headers_parse_response (headers, headers_len,
-					  req->response_headers,
+					  msg->response_headers,
 					  &version,
-					  &req->status_code,
-					  &req->reason_phrase)) {
+					  &msg->status_code,
+					  &msg->reason_phrase)) {
 		g_set_error_literal (error, SOUP_REQUEST_ERROR,
 				     SOUP_REQUEST_ERROR_PARSING,
 				     _("Could not parse HTTP response"));
 		return SOUP_STATUS_MALFORMED;
 	}
 
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_STATUS_CODE);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_REASON_PHRASE);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_STATUS_CODE);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_REASON_PHRASE);
 
 	if (version < priv->http_version) {
 		priv->http_version = version;
-		g_object_notify (G_OBJECT (req), SOUP_MESSAGE_HTTP_VERSION);
+		g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_HTTP_VERSION);
 	}
 
-	if ((req->method == SOUP_METHOD_HEAD ||
-	     req->status_code  == SOUP_STATUS_NO_CONTENT ||
-	     req->status_code  == SOUP_STATUS_NOT_MODIFIED ||
-	     SOUP_STATUS_IS_INFORMATIONAL (req->status_code)) ||
-	    (req->method == SOUP_METHOD_CONNECT &&
-	     SOUP_STATUS_IS_SUCCESSFUL (req->status_code)))
+	if ((msg->method == SOUP_METHOD_HEAD ||
+	     msg->status_code  == SOUP_STATUS_NO_CONTENT ||
+	     msg->status_code  == SOUP_STATUS_NOT_MODIFIED ||
+	     SOUP_STATUS_IS_INFORMATIONAL (msg->status_code)) ||
+	    (msg->method == SOUP_METHOD_CONNECT &&
+	     SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)))
 		*encoding = SOUP_ENCODING_NONE;
 	else
-		*encoding = soup_message_headers_get_encoding (req->response_headers);
+		*encoding = soup_message_headers_get_encoding (msg->response_headers);
 
 	if (*encoding == SOUP_ENCODING_UNRECOGNIZED) {
 		g_set_error_literal (error, SOUP_REQUEST_ERROR,
@@ -71,12 +71,12 @@ parse_response_headers (SoupMessage *req,
 }
 
 static void
-get_request_headers (SoupMessage *req, GString *header,
+get_request_headers (SoupMessage *msg, GString *header,
 		     SoupEncoding *encoding, gpointer user_data)
 {
-	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req);
+	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
 	SoupMessageQueueItem *item = user_data;
-	SoupURI *uri = soup_message_get_uri (req);
+	SoupURI *uri = soup_message_get_uri (msg);
 	char *uri_host;
 	char *uri_string;
 	SoupMessageHeadersIter iter;
@@ -89,7 +89,7 @@ get_request_headers (SoupMessage *req, GString *header,
 	else
 		uri_host = uri->host;
 
-	if (req->method == SOUP_METHOD_CONNECT) {
+	if (msg->method == SOUP_METHOD_CONNECT) {
 		/* CONNECT URI is hostname:port for tunnel destination */
 		uri_string = g_strdup_printf ("%s:%d", uri_host, uri->port);
 	} else {
@@ -109,10 +109,10 @@ get_request_headers (SoupMessage *req, GString *header,
 	}
 
 	g_string_append_printf (header, "%s %s HTTP/1.%d\r\n",
-				req->method, uri_string,
+				msg->method, uri_string,
 				(priv->http_version == SOUP_HTTP_1_0) ? 0 : 1);
 
-	if (!soup_message_headers_get_one (req->request_headers, "Host")) {
+	if (!soup_message_headers_get_one (msg->request_headers, "Host")) {
 		if (soup_uri_uses_default_port (uri)) {
 			g_string_append_printf (header, "Host: %s\r\n",
 						uri_host);
@@ -125,18 +125,18 @@ get_request_headers (SoupMessage *req, GString *header,
 	if (uri_host != uri->host)
 		g_free (uri_host);
 
-	*encoding = soup_message_headers_get_encoding (req->request_headers);
+	*encoding = soup_message_headers_get_encoding (msg->request_headers);
 	if ((*encoding == SOUP_ENCODING_CONTENT_LENGTH ||
 	     *encoding == SOUP_ENCODING_NONE) &&
-	    (req->request_body->length > 0 ||
-	     soup_message_headers_get_one (req->request_headers, "Content-Type")) &&
-	    !soup_message_headers_get_content_length (req->request_headers)) {
+	    (msg->request_body->length > 0 ||
+	     soup_message_headers_get_one (msg->request_headers, "Content-Type")) &&
+	    !soup_message_headers_get_content_length (msg->request_headers)) {
 		*encoding = SOUP_ENCODING_CONTENT_LENGTH;
-		soup_message_headers_set_content_length (req->request_headers,
-							 req->request_body->length);
+		soup_message_headers_set_content_length (msg->request_headers,
+							 msg->request_body->length);
 	}
 
-	soup_message_headers_iter_init (&iter, req->request_headers);
+	soup_message_headers_iter_init (&iter, msg->request_headers);
 	while (soup_message_headers_iter_next (&iter, &name, &value))
 		g_string_append_printf (header, "%s: %s\r\n", name, value);
 	g_string_append (header, "\r\n");
diff --git a/libsoup/soup-message-private.h b/libsoup/soup-message-private.h
index 53f8e81..74b6e0d 100644
--- a/libsoup/soup-message-private.h
+++ b/libsoup/soup-message-private.h
@@ -43,7 +43,7 @@ typedef struct {
 } SoupMessagePrivate;
 #define SOUP_MESSAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_MESSAGE, SoupMessagePrivate))
 
-void             soup_message_cleanup_response (SoupMessage      *req);
+void             soup_message_cleanup_response (SoupMessage      *msg);
 
 
 typedef void     (*SoupMessageGetHeadersFn)  (SoupMessage      *msg,
@@ -63,7 +63,7 @@ typedef void     (*SoupMessageCompletionFn)  (SoupMessage      *msg,
 void soup_message_send_request (SoupMessageQueueItem      *item,
 				SoupMessageCompletionFn    completion_cb,
 				gpointer                   user_data);
-void soup_message_read_request (SoupMessage               *req,
+void soup_message_read_request (SoupMessage               *msg,
 				SoupSocket                *sock,
 				SoupMessageCompletionFn    completion_cb,
 				gpointer                   user_data);
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 5362fc6..6c62b27 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -302,12 +302,12 @@ soup_message_get_property (GObject *object, guint prop_id,
 }
 
 static void
-soup_message_real_got_body (SoupMessage *req)
+soup_message_real_got_body (SoupMessage *msg)
 {
-	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req);
+	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
 	SoupMessageBody *body;
 
-	body = priv->server_side ? req->request_body : req->response_body;
+	body = priv->server_side ? msg->request_body : msg->response_body;
 	if (soup_message_body_get_accumulate (body)) {
 		SoupBuffer *buffer;
 
@@ -1262,39 +1262,39 @@ soup_message_get_proxy_auth (SoupMessage *msg)
 
 /**
  * soup_message_cleanup_response:
- * @req: a #SoupMessage
+ * @msg: a #SoupMessage
  *
- * Cleans up all response data on @req, so that the request can be sent
+ * Cleans up all response data on @msg, so that the request can be sent
  * again and receive a new response. (Eg, as a result of a redirect or
  * authorization request.)
  **/
 void
-soup_message_cleanup_response (SoupMessage *req)
+soup_message_cleanup_response (SoupMessage *msg)
 {
-	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req);
+	SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
 
-	soup_message_body_truncate (req->response_body);
-	soup_message_headers_clear (req->response_headers);
+	soup_message_body_truncate (msg->response_body);
+	soup_message_headers_clear (msg->response_headers);
 	if (priv->server_side) {
-		soup_message_headers_set_encoding (req->response_headers,
+		soup_message_headers_set_encoding (msg->response_headers,
 						   SOUP_ENCODING_CONTENT_LENGTH);
 	}
 
 	priv->msg_flags &= ~SOUP_MESSAGE_CONTENT_DECODED;
 
-	req->status_code = SOUP_STATUS_NONE;
-	if (req->reason_phrase) {
-		g_free (req->reason_phrase);
-		req->reason_phrase = NULL;
+	msg->status_code = SOUP_STATUS_NONE;
+	if (msg->reason_phrase) {
+		g_free (msg->reason_phrase);
+		msg->reason_phrase = NULL;
 	}
 	priv->http_version = priv->orig_http_version;
 
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_STATUS_CODE);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_REASON_PHRASE);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_HTTP_VERSION);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_FLAGS);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_TLS_CERTIFICATE);
-	g_object_notify (G_OBJECT (req), SOUP_MESSAGE_TLS_ERRORS);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_STATUS_CODE);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_REASON_PHRASE);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_HTTP_VERSION);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_FLAGS);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_TLS_CERTIFICATE);
+	g_object_notify (G_OBJECT (msg), SOUP_MESSAGE_TLS_ERRORS);
 }
 
 /**
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 1e462ea..cea950d 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -805,7 +805,7 @@ soup_server_get_handler (SoupServer *server, const char *path)
 }
 
 static void
-got_headers (SoupMessage *req, SoupClientContext *client)
+got_headers (SoupMessage *msg, SoupClientContext *client)
 {
 	SoupServer *server = client->server;
 	SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server);
@@ -820,14 +820,14 @@ got_headers (SoupMessage *req, SoupClientContext *client)
 	if (!priv->raw_paths) {
 		char *decoded_path;
 
-		uri = soup_message_get_uri (req);
+		uri = soup_message_get_uri (msg);
 		decoded_path = soup_uri_decode (uri->path);
 
 		if (strstr (decoded_path, "/../") ||
 		    g_str_has_suffix (decoded_path, "/..")) {
 			/* Introducing new ".." segments is not allowed */
 			g_free (decoded_path);
-			soup_message_set_status (req, SOUP_STATUS_BAD_REQUEST);
+			soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
 			return;
 		}
 
@@ -838,7 +838,7 @@ got_headers (SoupMessage *req, SoupClientContext *client)
 	/* Add required response headers */
 	date = soup_date_new_from_now (0);
 	date_string = soup_date_to_string (date, SOUP_DATE_HTTP);
-	soup_message_headers_replace (req->response_headers, "Date",
+	soup_message_headers_replace (msg->response_headers, "Date",
 				      date_string);
 	g_free (date_string);
 	soup_date_free (date);
@@ -851,8 +851,8 @@ got_headers (SoupMessage *req, SoupClientContext *client)
 	for (iter = priv->auth_domains; iter; iter = iter->next) {
 		domain = iter->data;
 
-		if (soup_auth_domain_covers (domain, req)) {
-			auth_user = soup_auth_domain_accepts (domain, req);
+		if (soup_auth_domain_covers (domain, msg)) {
+			auth_user = soup_auth_domain_accepts (domain, msg);
 			if (auth_user) {
 				client->auth_domain = g_object_ref (domain);
 				client->auth_user = auth_user;
@@ -870,27 +870,27 @@ got_headers (SoupMessage *req, SoupClientContext *client)
 	for (iter = priv->auth_domains; iter; iter = iter->next) {
 		domain = iter->data;
 
-		if (soup_auth_domain_covers (domain, req))
-			soup_auth_domain_challenge (domain, req);
+		if (soup_auth_domain_covers (domain, msg))
+			soup_auth_domain_challenge (domain, msg);
 	}
 }
 
 static void
-call_handler (SoupMessage *req, SoupClientContext *client)
+call_handler (SoupMessage *msg, SoupClientContext *client)
 {
 	SoupServer *server = client->server;
 	SoupServerHandler *hand;
 	SoupURI *uri;
 
-	g_signal_emit (server, signals[REQUEST_READ], 0, req, client);
+	g_signal_emit (server, signals[REQUEST_READ], 0, msg, client);
 
-	if (req->status_code != 0)
+	if (msg->status_code != 0)
 		return;
 
-	uri = soup_message_get_uri (req);
+	uri = soup_message_get_uri (msg);
 	hand = soup_server_get_handler (server, uri->path);
 	if (!hand) {
-		soup_message_set_status (req, SOUP_STATUS_NOT_FOUND);
+		soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND);
 		return;
 	}
 
@@ -903,7 +903,7 @@ call_handler (SoupMessage *req, SoupClientContext *client)
 			form_data_set = NULL;
 
 		/* Call method handler */
-		(*hand->callback) (server, req,
+		(*hand->callback) (server, msg,
 				   uri->path, form_data_set,
 				   client, hand->user_data);
 
diff --git a/libsoup/soup-session-async.c b/libsoup/soup-session-async.c
index 4c08a61..c416646 100644
--- a/libsoup/soup-session-async.c
+++ b/libsoup/soup-session-async.c
@@ -69,25 +69,25 @@ soup_session_async_new_with_options (const char *optname1, ...)
 }
 
 static void
-soup_session_async_queue_message (SoupSession *session, SoupMessage *req,
+soup_session_async_queue_message (SoupSession *session, SoupMessage *msg,
 				  SoupSessionCallback callback, gpointer user_data)
 {
 	SoupMessageQueueItem *item;
 
-	item = soup_session_append_queue_item (session, req, TRUE, FALSE,
+	item = soup_session_append_queue_item (session, msg, TRUE, FALSE,
 					       callback, user_data);
 	soup_session_kick_queue (session);
 	soup_message_queue_item_unref (item);
 }
 
 static guint
-soup_session_async_send_message (SoupSession *session, SoupMessage *req)
+soup_session_async_send_message (SoupSession *session, SoupMessage *msg)
 {
 	SoupMessageQueueItem *item;
 	GMainContext *async_context =
 		soup_session_get_async_context (session);
 
-	item = soup_session_append_queue_item (session, req, TRUE, FALSE,
+	item = soup_session_append_queue_item (session, msg, TRUE, FALSE,
 					       NULL, NULL);
 	soup_session_kick_queue (session);
 
@@ -96,7 +96,7 @@ soup_session_async_send_message (SoupSession *session, SoupMessage *req)
 
 	soup_message_queue_item_unref (item);
 
-	return req->status_code;
+	return msg->status_code;
 }
 
 static void



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