diff options
author | Dan Winship <danw@src.gnome.org> | 2006-05-26 18:14:37 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2006-05-26 18:14:37 +0000 |
commit | 631e4c36a7d8653263441743a21e6b0ded478857 (patch) | |
tree | f2894c223a0c9879a0e50c2f8b010b3a7813df23 /libsoup | |
parent | 318d622c1f03c8165ee9f7ab0aaf38c46f06ef60 (diff) | |
download | libsoup-631e4c36a7d8653263441743a21e6b0ded478857.tar.gz |
Start SSL after CONNECTing! Doh. Part of bnc #174255.
* libsoup/soup-connection.c (soup_connection_connect_sync): Start
SSL after CONNECTing! Doh. Part of bnc #174255.
(SoupConnectionMode): new enum for the three types of
SoupConnection (direct, proxy, tunnel).
(set_property): set priv->mode according to proxy_uri and
conn_uri.
(socket_connect_result, soup_connection_connect_sync): use
priv->mode to decide whether or not to tunnel.
(send_request): Only pass TRUE for is_proxy to
soup_message_send_request if mode is PROXY, not if it's TUNNEL.
(Also part of bnc #174255).
Diffstat (limited to 'libsoup')
-rw-r--r-- | libsoup/soup-connection.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c index c6622d4e..e8544d3b 100644 --- a/libsoup/soup-connection.c +++ b/libsoup/soup-connection.c @@ -28,6 +28,12 @@ #include "soup-ssl.h" #include "soup-uri.h" +typedef enum { + SOUP_CONNECTION_MODE_DIRECT, + SOUP_CONNECTION_MODE_PROXY, + SOUP_CONNECTION_MODE_TUNNEL +} SoupConnectionMode; + typedef struct { SoupSocket *socket; @@ -40,6 +46,8 @@ typedef struct { SoupUri *proxy_uri, *origin_uri, *conn_uri; gpointer ssl_creds; + SoupConnectionMode mode; + SoupMessageFilter *filter; GMainContext *async_context; @@ -310,17 +318,26 @@ set_property (GObject *object, guint prop_id, case PROP_ORIGIN_URI: pval = g_value_get_pointer (value); priv->origin_uri = pval ? soup_uri_copy (pval) : NULL; - if (!priv->proxy_uri) - priv->conn_uri = priv->origin_uri; - break; + goto changed_uri; + case PROP_PROXY_URI: pval = g_value_get_pointer (value); priv->proxy_uri = pval ? soup_uri_copy (pval) : NULL; - if (priv->proxy_uri) + + changed_uri: + if (priv->proxy_uri) { priv->conn_uri = priv->proxy_uri; - else + if (priv->origin_uri && + priv->origin_uri->protocol == SOUP_PROTOCOL_HTTPS) + priv->mode = SOUP_CONNECTION_MODE_TUNNEL; + else + priv->mode = SOUP_CONNECTION_MODE_PROXY; + } else { priv->conn_uri = priv->origin_uri; + priv->mode = SOUP_CONNECTION_MODE_DIRECT; + } break; + case PROP_SSL_CREDS: priv->ssl_creds = g_value_get_pointer (value); break; @@ -502,10 +519,7 @@ socket_connect_result (SoupSocket *sock, guint status, gpointer user_data) } } - /* See if we need to tunnel */ - if (priv->proxy_uri && - priv->origin_uri && - priv->origin_uri->protocol == SOUP_PROTOCOL_HTTPS) { + if (priv->mode == SOUP_CONNECTION_MODE_TUNNEL) { SoupMessage *connect_msg; connect_msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, @@ -608,10 +622,7 @@ soup_connection_connect_sync (SoupConnection *conn) } } - /* See if we need to tunnel */ - if (priv->proxy_uri && - priv->origin_uri && - priv->origin_uri->protocol == SOUP_PROTOCOL_HTTPS) { + if (priv->mode == SOUP_CONNECTION_MODE_TUNNEL) { SoupMessage *connect_msg; connect_msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, @@ -630,6 +641,12 @@ soup_connection_connect_sync (SoupConnection *conn) } g_object_unref (connect_msg); + + if (SOUP_STATUS_IS_SUCCESSFUL (status)) { + if (!soup_socket_start_proxy_ssl (priv->socket, + priv->origin_uri->host)) + status = SOUP_STATUS_SSL_FAILED; + } } if (SOUP_STATUS_IS_SUCCESSFUL (status)) @@ -767,7 +784,7 @@ send_request (SoupConnection *conn, SoupMessage *req) } soup_message_send_request_internal (req, priv->socket, conn, - priv->proxy_uri != NULL); + priv->mode == SOUP_CONNECTION_MODE_PROXY); } /** |