[glib] [gio] Terminate connect call when application proxy is used



commit cb74c366783944057492bae1e6b9472e36e2e7f1
Author: Nicolas Dufresne <nicolas dufresne collabora co uk>
Date:   Thu Nov 17 13:04:04 2011 -0500

    [gio] Terminate connect call when application proxy is used
    
    The connect_async() calls would never terminated when an application side
    proxy was being used. Note we also skip over TLS handshake in this case,
    as the application may have to do some proxy handshake before.

 gio/gsocketclient.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index e65404f..d14234d 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -804,6 +804,7 @@ g_socket_client_connect (GSocketClient       *client,
   while (connection == NULL)
     {
       GSocketAddress *address = NULL;
+      gboolean application_proxy = FALSE;
       GSocket *socket;
 
       if (g_cancellable_is_cancelled (cancellable))
@@ -897,9 +898,13 @@ g_socket_client_connect (GSocketClient       *client,
 	      g_object_unref (connection);
 	      connection = NULL;
 	    }
+	  else
+	    {
+	      application_proxy = TRUE;
+	    }
 	}
 
-      if (connection && client->priv->tls)
+      if (!application_proxy && connection && client->priv->tls)
 	{
 	  GIOStream *tlsconn;
 
@@ -1307,6 +1312,12 @@ g_socket_client_proxy_connect (GSocketClientAsyncConnectData *data)
 
       enumerator_next_async (data);
     }
+  else
+    {
+      /* Simply complete the connection, we don't want to do TLS handshake
+       * as the application proxy handling may need proxy handshake first */
+      g_socket_client_async_connect_complete (data);
+    }
 }
 
 static void
@@ -1715,6 +1726,10 @@ g_socket_client_connect_to_uri_finish (GSocketClient  *client,
  * proxy protocols that are reused between protocols. A good example
  * is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also
  * be use as generic socket proxy through the HTTP CONNECT method.
+ *
+ * When the proxy is detected as being an application proxy, TLS handshake
+ * will be skipped. This is required to let the application do the proxy
+ * specific handshake.
  */
 void
 g_socket_client_add_application_proxy (GSocketClient *client,



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