[libsoup] Replace remote-uri with remote-connectable in SoupConnection
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Replace remote-uri with remote-connectable in SoupConnection
- Date: Fri, 5 Mar 2021 09:11:44 +0000 (UTC)
commit d8899fb9e5ef5b2531863f65a3d4eb60d4c3160c
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Mar 2 10:36:29 2021 +1300
Replace remote-uri with remote-connectable in SoupConnection
libsoup/soup-connection.c | 53 ++++++++++++-----------------------------------
libsoup/soup-session.c | 15 ++++++++++----
2 files changed, 24 insertions(+), 44 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 24a466a4..4d729678 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -27,7 +27,7 @@ typedef struct {
GIOStream *iostream;
SoupSocketProperties *socket_props;
- GUri *remote_uri, *proxy_uri;
+ GUri *proxy_uri;
gboolean ssl;
SoupMessage *current_msg;
@@ -53,7 +53,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
- PROP_REMOTE_URI,
+ PROP_REMOTE_CONNECTABLE,
PROP_SOCKET_PROPERTIES,
PROP_STATE,
PROP_SSL,
@@ -80,7 +80,6 @@ soup_connection_finalize (GObject *object)
{
SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
- g_clear_pointer (&priv->remote_uri, g_uri_unref);
g_clear_pointer (&priv->proxy_uri, g_uri_unref);
g_clear_pointer (&priv->socket_props, soup_socket_properties_unref);
g_clear_object (&priv->remote_connectable);
@@ -120,8 +119,8 @@ soup_connection_set_property (GObject *object, guint prop_id,
SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
switch (prop_id) {
- case PROP_REMOTE_URI:
- priv->remote_uri = g_value_dup_boxed (value);
+ case PROP_REMOTE_CONNECTABLE:
+ priv->remote_connectable = g_value_dup_object (value);
break;
case PROP_SOCKET_PROPERTIES:
priv->socket_props = g_value_dup_boxed (value);
@@ -145,8 +144,8 @@ soup_connection_get_property (GObject *object, guint prop_id,
SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
switch (prop_id) {
- case PROP_REMOTE_URI:
- g_value_set_boxed (value, priv->remote_uri);
+ case PROP_REMOTE_CONNECTABLE:
+ g_value_set_object (value, priv->remote_connectable);
break;
case PROP_SOCKET_PROPERTIES:
g_value_set_boxed (value, priv->socket_props);
@@ -212,13 +211,13 @@ soup_connection_class_init (SoupConnectionClass *connection_class)
/* properties */
g_object_class_install_property (
- object_class, PROP_REMOTE_URI,
- g_param_spec_boxed ("remote-uri",
- "Remote URI",
- "The URI of the HTTP server",
- G_TYPE_URI,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ object_class, PROP_REMOTE_CONNECTABLE,
+ g_param_spec_object ("remote-connectable",
+ "Remote Connectable",
+ "Socket to connect to make outgoing connections on",
+ G_TYPE_SOCKET_CONNECTABLE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class, PROP_SOCKET_PROPERTIES,
g_param_spec_boxed ("socket-properties",
@@ -604,14 +603,6 @@ soup_connection_connect_async (SoupConnection *conn,
soup_connection_set_state (conn, SOUP_CONNECTION_CONNECTING);
- /* Set the protocol to ensure correct proxy resolution. */
- priv->remote_connectable =
- g_object_new (G_TYPE_NETWORK_ADDRESS,
- "hostname", g_uri_get_host (priv->remote_uri),
- "port", g_uri_get_port (priv->remote_uri),
- "scheme", g_uri_get_scheme (priv->remote_uri),
- NULL);
-
priv->cancellable = cancellable ? g_object_ref (cancellable) : g_cancellable_new ();
task = g_task_new (conn, priv->cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
@@ -648,14 +639,6 @@ soup_connection_connect (SoupConnection *conn,
soup_connection_set_state (conn, SOUP_CONNECTION_CONNECTING);
- /* Set the protocol to ensure correct proxy resolution. */
- priv->remote_connectable =
- g_object_new (G_TYPE_NETWORK_ADDRESS,
- "hostname", g_uri_get_host (priv->remote_uri),
- "port", g_uri_get_port (priv->remote_uri),
- "scheme", g_uri_get_scheme (priv->remote_uri),
- NULL);
-
priv->cancellable = cancellable ? g_object_ref (cancellable) : g_cancellable_new ();
client = new_socket_client (conn);
@@ -897,16 +880,6 @@ soup_connection_steal_iostream (SoupConnection *conn)
return iostream;
}
-GUri *
-soup_connection_get_remote_uri (SoupConnection *conn)
-{
- SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
-
- g_return_val_if_fail (SOUP_IS_CONNECTION (conn), NULL);
-
- return priv->remote_uri;
-}
-
GUri *
soup_connection_get_proxy_uri (SoupConnection *conn)
{
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index c2a2a3cb..2b050169 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1664,13 +1664,11 @@ tunnel_connect (SoupMessageQueueItem *item)
{
SoupSession *session = item->session;
SoupMessageQueueItem *tunnel_item;
- GUri *uri;
SoupMessage *msg;
item->state = SOUP_MESSAGE_TUNNELING;
- uri = soup_connection_get_remote_uri (item->conn);
- msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, uri);
+ msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, soup_message_get_uri (item->msg));
soup_message_add_flags (msg, SOUP_MESSAGE_NO_REDIRECT);
tunnel_item = soup_session_append_queue_item (session, msg,
@@ -1770,6 +1768,7 @@ get_connection_for_host (SoupSession *session,
gboolean *try_cleanup)
{
SoupSessionPrivate *priv = soup_session_get_instance_private (session);
+ GSocketConnectable *remote_connectable;
SoupConnection *conn;
GSList *conns;
guint num_pending = 0;
@@ -1820,12 +1819,20 @@ get_connection_for_host (SoupSession *session,
return NULL;
}
+ remote_connectable =
+ g_object_new (G_TYPE_NETWORK_ADDRESS,
+ "hostname", g_uri_get_host (host->uri),
+ "port", g_uri_get_port (host->uri),
+ "scheme", g_uri_get_scheme (host->uri),
+ NULL);
+
ensure_socket_props (session);
conn = g_object_new (SOUP_TYPE_CONNECTION,
- "remote-uri", host->uri,
+ "remote-connectable", remote_connectable,
"ssl", soup_uri_is_https (host->uri),
"socket-properties", priv->socket_props,
NULL);
+ g_object_unref (remote_connectable);
g_signal_connect (conn, "disconnected",
G_CALLBACK (connection_disconnected),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]