diff options
author | Dan Winship <danw@gnome.org> | 2014-03-15 09:23:32 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-05-02 08:47:05 -0400 |
commit | f2a22c9949ea625c7826f0f93144befb707bedf6 (patch) | |
tree | 623c2d12c9c814cae89c4d99865f5f07c006ec3b | |
parent | a31a04c0ed2b420e6772f1ec835bc5ff8b4a85f9 (diff) | |
download | libsoup-f2a22c9949ea625c7826f0f93144befb707bedf6.tar.gz |
soup-session, soup-connection: update handling of "ssl" flag
Store all SoupSessionHosts with a URI using either "http" or "https"
as the scheme. Then we don't need to explicitly tell SoupConnection
whether the connection is SSL or not, since it can figure it out from
the URI.
-rw-r--r-- | libsoup/soup-connection.c | 18 | ||||
-rw-r--r-- | libsoup/soup-connection.h | 1 | ||||
-rw-r--r-- | libsoup/soup-session.c | 15 |
3 files changed, 16 insertions, 18 deletions
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c index fce589fa..9e688183 100644 --- a/libsoup/soup-connection.c +++ b/libsoup/soup-connection.c @@ -51,7 +51,6 @@ enum { PROP_LOCAL_ADDRESS, PROP_REMOTE_URI, PROP_PROXY_RESOLVER, - PROP_SSL, PROP_SSL_CREDS, PROP_SSL_STRICT, PROP_SSL_FALLBACK, @@ -119,13 +118,14 @@ soup_connection_set_property (GObject *object, guint prop_id, break; case PROP_REMOTE_URI: priv->remote_uri = g_value_dup_boxed (value); + if (priv->remote_uri) + priv->ssl = (priv->remote_uri->scheme == SOUP_URI_SCHEME_HTTPS); + else + priv->ssl = FALSE; break; case PROP_PROXY_RESOLVER: priv->proxy_resolver = g_value_dup_object (value); break; - case PROP_SSL: - priv->ssl = g_value_get_boolean (value); - break; case PROP_SSL_CREDS: if (priv->tlsdb) g_object_unref (priv->tlsdb); @@ -173,9 +173,6 @@ soup_connection_get_property (GObject *object, guint prop_id, case PROP_REMOTE_URI: g_value_set_boxed (value, priv->remote_uri); break; - case PROP_SSL: - g_value_set_boolean (value, priv->ssl); - break; case PROP_SSL_CREDS: g_value_set_object (value, priv->tlsdb); break; @@ -262,13 +259,6 @@ soup_connection_class_init (SoupConnectionClass *connection_class) G_TYPE_PROXY_RESOLVER, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property ( - object_class, PROP_SSL, - g_param_spec_boolean (SOUP_CONNECTION_SSL, - "SSL", - "Whether this is an SSL connection", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property ( object_class, PROP_SSL_CREDS, g_param_spec_object (SOUP_CONNECTION_SSL_CREDENTIALS, "SSL credentials", diff --git a/libsoup/soup-connection.h b/libsoup/soup-connection.h index b70a8a36..454432dd 100644 --- a/libsoup/soup-connection.h +++ b/libsoup/soup-connection.h @@ -38,7 +38,6 @@ GType soup_connection_get_type (void); #define SOUP_CONNECTION_LOCAL_ADDRESS "local-address" #define SOUP_CONNECTION_REMOTE_URI "remote-uri" #define SOUP_CONNECTION_PROXY_RESOLVER "proxy-resolver" -#define SOUP_CONNECTION_SSL "ssl" #define SOUP_CONNECTION_SSL_CREDENTIALS "ssl-creds" #define SOUP_CONNECTION_SSL_STRICT "ssl-strict" #define SOUP_CONNECTION_SSL_FALLBACK "ssl-fallback" diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index 132554d6..96bf4b62 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -959,17 +959,27 @@ get_host_for_uri (SoupSession *session, SoupURI *uri) { SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); SoupSessionHost *host; + gboolean https; + SoupURI *uri_tmp = NULL; - if (soup_uri_is_https (uri, priv->https_aliases)) + https = soup_uri_is_https (uri, priv->https_aliases); + if (https) host = g_hash_table_lookup (priv->https_hosts, uri); else host = g_hash_table_lookup (priv->http_hosts, uri); if (host) return host; + if (uri->scheme != SOUP_URI_SCHEME_HTTP && + uri->scheme != SOUP_URI_SCHEME_HTTPS) { + uri = uri_tmp = soup_uri_copy (uri); + uri->scheme = https ? SOUP_URI_SCHEME_HTTPS : SOUP_URI_SCHEME_HTTP; + } host = soup_session_host_new (session, uri); + if (uri_tmp) + soup_uri_free (uri_tmp); - if (soup_uri_is_https (uri, priv->https_aliases)) + if (https) g_hash_table_insert (priv->https_hosts, host->uri, host); else g_hash_table_insert (priv->http_hosts, host->uri, host); @@ -1774,7 +1784,6 @@ get_connection_for_host (SoupSession *session, SOUP_TYPE_CONNECTION, SOUP_CONNECTION_REMOTE_URI, host->uri, SOUP_CONNECTION_PROXY_RESOLVER, proxy_resolver, - SOUP_CONNECTION_SSL, soup_uri_is_https (soup_message_get_uri (item->msg), priv->https_aliases), SOUP_CONNECTION_SSL_CREDENTIALS, tlsdb, SOUP_CONNECTION_SSL_STRICT, priv->ssl_strict && (tlsdb != NULL || SOUP_IS_PLAIN_SESSION (session)), SOUP_CONNECTION_ASYNC_CONTEXT, priv->async_context, |