changeset 4547:a8b6a570543b

RH735336: Use GSettings to obtain proxy settings rather than deprecated GConf
author andrew
date Sun, 18 Sep 2011 17:00:57 +0100
parents 80fe75968a0b
children 0cb15650412a
files make/java/net/FILES_c.gmk make/java/net/Makefile src/solaris/native/common/deps/gconf2/gconf_fp.h src/solaris/native/common/deps/glib2/gio/gio.h src/solaris/native/common/deps/glib2/gio_fp.c src/solaris/native/common/deps/glib2/gio_fp.h src/solaris/native/sun/net/spi/DefaultProxySelector.c
diffstat 7 files changed, 301 insertions(+), 164 deletions(-) [+]
line wrap: on
line diff
--- a/make/java/net/FILES_c.gmk	Fri Sep 09 16:57:05 2011 +0100
+++ b/make/java/net/FILES_c.gmk	Sun Sep 18 17:00:57 2011 +0100
@@ -56,3 +56,7 @@
 ifndef USE_SYSTEM_GCONF
    FILES_c += gconf_fp.c
 endif
+
+ifndef USE_SYSTEM_GIO
+   FILES_c += gio_fp.c
+endif
--- a/make/java/net/Makefile	Fri Sep 09 16:57:05 2011 +0100
+++ b/make/java/net/Makefile	Sun Sep 18 17:00:57 2011 +0100
@@ -88,6 +88,10 @@
   vpath %.c	$(PLATFORM_SRC)/native/common/deps/gconf2
 endif
 
+ifndef USE_SYSTEM_GIO
+  vpath %.c     $(PLATFORM_SRC)/native/common/deps/glib2
+endif
+
 #
 # Include rules
 #
@@ -114,6 +118,14 @@
   OTHER_LDLIBS += -ldl
 endif
 
+ifdef USE_SYSTEM_GIO
+  OTHER_LDLIBS += $(GIO_LIBS)
+  CPPFLAGS += $(GIO_CFLAGS) -DUSE_SYSTEM_GIO
+else
+  CPPFLAGS += -I$(PLATFORM_SRC)/native/common/deps/glib2
+  OTHER_LDLIBS += -ldl
+endif
+
 CLASSES.export += java.lang.Integer java.io.FileDescriptor java.net.InetAddressImplFactory java.net.Inet4AddressImpl java.net.Inet6AddressImpl
 
 #
--- a/src/solaris/native/common/deps/gconf2/gconf_fp.h	Fri Sep 09 16:57:05 2011 +0100
+++ b/src/solaris/native/common/deps/gconf2/gconf_fp.h	Sun Sep 18 17:00:57 2011 +0100
@@ -42,7 +42,6 @@
 #define gconf_client_get_int (*my_get_int_func)
 #define gconf_client_get_bool (*my_get_bool_func)
 #define gconf_init (*my_gconf_init_func)
-#define g_type_init (*my_g_type_init_func)
 
 jboolean init_gconf(int* gconf_ver, void** gconf_client);
 
--- a/src/solaris/native/common/deps/glib2/gio/gio.h	Fri Sep 09 16:57:05 2011 +0100
+++ b/src/solaris/native/common/deps/glib2/gio/gio.h	Sun Sep 18 17:00:57 2011 +0100
@@ -33,11 +33,13 @@
 typedef void* gpointer;
 typedef int    gint;
 typedef gint   gboolean;
+typedef char   gchar;
 typedef struct _GFile GFile;
 typedef struct _GFileInfo GFileInfo;
 typedef struct _GCancellable GCancellable;
 typedef struct _GError GError;
 typedef struct _GAppLaunchContext GAppLaunchContext;
+typedef struct _GSettings GSettings;
 
 typedef enum {
   G_FILE_QUERY_INFO_NONE = 0
@@ -53,5 +55,13 @@
 typedef gboolean  (*app_info_launch_default_for_uri_func)(const char              *uri,
 							  GAppLaunchContext       *launch_context,
 							  GError                 **error);
+typedef GSettings* (*settings_new_func) (const gchar *schema);
+typedef gboolean (*settings_get_boolean_func) (GSettings *settings, const gchar *key);
+typedef gchar* (*settings_get_string_func) (GSettings *settings, const gchar *key);
+typedef gchar** (*settings_get_strv_func) (GSettings *settings, const gchar *key);
+typedef gint (*settings_get_int_func) (GSettings *settings, const gchar *key);
+typedef GSettings* (*settings_get_child_func) (GSettings *settings, const gchar *name);
+typedef void (*strfreev_func) (gchar **str_array);
+typedef void (*free_func) (gpointer mem);
 
 #endif
--- a/src/solaris/native/common/deps/glib2/gio_fp.c	Fri Sep 09 16:57:05 2011 +0100
+++ b/src/solaris/native/common/deps/glib2/gio_fp.c	Sun Sep 18 17:00:57 2011 +0100
@@ -34,6 +34,14 @@
 file_query_info_func file_query_info;
 file_info_get_content_type_func file_info_get_content_type;
 app_info_launch_default_for_uri_func app_info_launch_default_for_uri;
+settings_new_func settings_new;
+settings_get_boolean_func settings_get_boolean;
+settings_get_string_func settings_get_string;
+settings_get_strv_func settings_get_strv;
+settings_get_int_func settings_get_int;
+settings_get_child_func settings_get_child;
+strfreev_func gstrfreev;
+free_func gfree;
 
 jboolean gio_init()
 {
@@ -64,12 +72,34 @@
     app_info_launch_default_for_uri = (app_info_launch_default_for_uri_func)
 	dlsym (gio_handle, "g_app_info_launch_default_for_uri");
 
+    settings_new = (settings_new_func) dlsym (gio_handle, "g_settings_new");
+    settings_get_boolean = (settings_get_boolean_func)
+      dlsym (gio_handle, "g_settings_get_boolean");
+    settings_get_string = (settings_get_string_func)
+      dlsym (gio_handle, "g_settings_get_string");
+    settings_get_strv = (settings_get_strv_func)
+      dlsym (gio_handle, "g_settings_get_strv");
+    settings_get_int = (settings_get_int_func)
+      dlsym (gio_handle, "g_settings_get_int");
+    settings_get_child = (settings_get_child_func)
+      dlsym (gio_handle, "g_settings_get_child");
+    gstrfreev = (strfreev_func) dlsym (gio_handle, "g_strfreev");
+    gfree = (free_func) dlsym (gio_handle, "g_free");
+
     if (type_init == NULL ||
         object_unref == NULL ||
         file_new_for_path == NULL ||
         file_query_info == NULL ||
         file_info_get_content_type == NULL ||
-	app_info_launch_default_for_uri == NULL)
+	app_info_launch_default_for_uri == NULL ||
+	settings_new == NULL ||
+	settings_get_boolean == NULL ||
+	settings_get_string == NULL ||
+	settings_get_strv == NULL ||
+	settings_get_int == NULL ||
+	settings_get_child == NULL ||
+	gstrfreev == NULL ||
+	gfree == NULL)
     {
         dlclose(gio_handle);
         return JNI_FALSE;
--- a/src/solaris/native/common/deps/glib2/gio_fp.h	Fri Sep 09 16:57:05 2011 +0100
+++ b/src/solaris/native/common/deps/glib2/gio_fp.h	Sun Sep 18 17:00:57 2011 +0100
@@ -34,6 +34,14 @@
 extern file_query_info_func file_query_info;
 extern file_info_get_content_type_func file_info_get_content_type;
 extern app_info_launch_default_for_uri_func app_info_launch_default_for_uri;
+extern settings_new_func settings_new;
+extern settings_get_boolean_func settings_get_boolean;
+extern settings_get_string_func settings_get_string;
+extern settings_get_strv_func settings_get_strv;
+extern settings_get_int_func settings_get_int;
+extern settings_get_child_func settings_get_child;
+extern strfreev_func gstrfreev;
+extern free_func gfree;
 
 #define g_type_init (*type_init)
 #define g_object_unref (*object_unref)
@@ -41,6 +49,14 @@
 #define g_file_query_info (*file_query_info)
 #define g_file_info_get_content_type (*file_info_get_content_type)
 #define g_app_info_launch_default_for_uri (*app_info_launch_default_for_uri)
+#define g_settings_new (*settings_new)
+#define g_settings_get_boolean (*settings_get_boolean)
+#define g_settings_get_string (*settings_get_string)
+#define g_settings_get_strv (*settings_get_strv)
+#define g_settings_get_int (*settings_get_int)
+#define g_settings_get_child (*settings_get_child)
+#define g_strfreev (*gstrfreev)
+#define g_free (*gfree)
 
 jboolean gio_init();
 
--- a/src/solaris/native/sun/net/spi/DefaultProxySelector.c	Fri Sep 09 16:57:05 2011 +0100
+++ b/src/solaris/native/sun/net/spi/DefaultProxySelector.c	Sun Sep 18 17:00:57 2011 +0100
@@ -35,8 +35,13 @@
 #include <strings.h>
 #endif
 
+#include <gio/gio.h>
 #include <gconf/gconf-client.h>
 
+#ifndef USE_SYSTEM_GIO
+#include <gio_fp.h>
+#endif
+
 #ifndef USE_SYSTEM_GCONF
 #include <gconf_fp.h>
 #endif
@@ -52,6 +57,7 @@
 
 static int gconf_ver = 0;
 static void* gconf_client = NULL;
+static jboolean use_gio;
 
 #define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); }
 
@@ -96,16 +102,26 @@
   ptype_socksID = (*env)->GetStaticFieldID(env, ptype_class, "SOCKS", "Ljava/net/Proxy$Type;");
   isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved", "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;");
 
-#ifdef USE_SYSTEM_GCONF
-  gconf_ver = 2;
-  return JNI_TRUE;
+#ifdef USE_SYSTEM_GIO
+  use_gio = JNI_TRUE;
+  g_type_init ();
 #else
-  return init_gconf (&gconf_ver, &gconf_client);
+  use_gio = gio_init();
 #endif
 
+  if (use_gio == JNI_TRUE) {
+    return use_gio;
+  } else {
+#ifdef USE_SYSTEM_GCONF
+    gconf_ver = 2;
+    return JNI_TRUE;
+#else
+    return init_gconf (&gconf_ver, &gconf_client);
+#endif
+  }
+
 }
 
-
 /*
  * Class:     sun_net_spi_DefaultProxySelector
  * Method:    getSystemProxy
@@ -120,176 +136,226 @@
   char *phost = NULL;
   char *mode = NULL;
   int pport = 0;
-  int use_proxy = 0;
-  int use_same_proxy = 0;
+  gboolean use_proxy = 0;
+  gboolean use_same_proxy = 0;
   const char* urlhost;
   jobject isa = NULL;
   jobject proxy = NULL;
   jobject type_proxy = NULL;
   jobject no_proxy = NULL;
-  const char *cproto;
   jboolean isCopy;
 
-  if (gconf_ver > 0) {
-    if (gconf_client == NULL) {
-      g_type_init();
-      gconf_client = gconf_client_get_default();
-    }
-    if (gconf_client != NULL) {
-      cproto = (*env)->GetStringUTFChars(env, proto, &isCopy);
-      if (cproto != NULL) {
-        /**
-         * We will have to check protocol by protocol as they do use different
-         * entries.
-         */
+  if (use_gio == JNI_TRUE || gconf_ver > 0) {
+    jstring jhost;
+    const char *cproto;
+    char *used_proto;
+
+    cproto = (*env)->GetStringUTFChars(env, proto, &isCopy);
+
+    if (use_gio == JNI_TRUE && cproto != NULL) {
+      GSettings *settings, *child_settings;
+      gchar **ignored;
+
+      settings = g_settings_new ("org.gnome.system.proxy");
 
-        use_same_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_same_proxy", NULL);
-        if (use_same_proxy) {
-          use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL);
-          if (use_proxy) {
-            phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL);
-            pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL);
-          }
-        }
+      use_same_proxy = g_settings_get_boolean (settings, "use-same-proxy");
+      if (use_same_proxy) {
+	used_proto = "http";
+      } else {
+	used_proto = (char*) cproto;
+      }
+
+      mode = g_settings_get_string (settings, "mode");
+      use_proxy = (mode != NULL && strcasecmp (mode, "manual") == 0);
+
+      child_settings = g_settings_get_child (settings, used_proto);
+      if (use_proxy && strcasecmp (used_proto, "http") == 0) {
+	use_proxy = g_settings_get_boolean (child_settings, "enabled");
+      }
+
+      if (use_proxy) {
+	phost = g_settings_get_string (child_settings, "host");
+	pport = g_settings_get_int (child_settings, "port");
+      }
 
-        /**
-         * HTTP:
-         * /system/http_proxy/use_http_proxy (boolean)
-         * /system/http_proxy/host (string)
-         * /system/http_proxy/port (integer)
-         */
-        if (strcasecmp(cproto, "http") == 0) {
-          use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL);
-          if (use_proxy) {
-            if (!use_same_proxy) {
-              phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL);
-              pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL);
-            }
-            CHECK_NULL(type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID));
-          }
-        }
+      ignored = g_settings_get_strv (settings, "ignore-hosts");
+      if (ignored != NULL) {
+	char **ptr;
+	size_t urlhost_len, s_len;
+	
+	urlhost = (*env)->GetStringUTFChars(env, host, &isCopy);
+	urlhost_len = strlen (urlhost);
+	if (urlhost != NULL) {
+	  for (ptr = ignored; *ptr != NULL; ++ptr) {
+	    s_len = strlen (*ptr);
+	    if (s_len <= urlhost_len) {
+	      if (strcasecmp (urlhost + (urlhost_len - s_len), *ptr) == 0) {
+		use_proxy = 0;
+		break;
+	      }
+	    }
+	  }
+	  if (isCopy == JNI_TRUE)
+	    (*env)->ReleaseStringUTFChars(env, host, urlhost);
+	}
+	
+	g_strfreev (ignored);
+	g_object_unref (child_settings);
+	g_object_unref (settings);
+      }
+    } else {
+      if (gconf_client == NULL) {
+	g_type_init();
+	gconf_client = gconf_client_get_default();
+      }
 
-        /**
-         * HTTPS:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/secure_host (string)
-         * /system/proxy/secure_port (integer)
-         */
-        if (strcasecmp(cproto, "https") == 0) {
-          mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = gconf_client_get_string(gconf_client, "/system/proxy/secure_host", NULL);
-              pport = gconf_client_get_int(gconf_client, "/system/proxy/secure_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
-
-        /**
-         * FTP:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/ftp_host (string)
-         * /system/proxy/ftp_port (integer)
-         */
-        if (strcasecmp(cproto, "ftp") == 0) {
-          mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = gconf_client_get_string(gconf_client, "/system/proxy/ftp_host", NULL);
-              pport = gconf_client_get_int(gconf_client, "/system/proxy/ftp_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
+      if (gconf_client != NULL) {
+	char *noproxyfor;
+	char *s;
 
-        /**
-         * GOPHER:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/gopher_host (string)
-         * /system/proxy/gopher_port (integer)
-         */
-        if (strcasecmp(cproto, "gopher") == 0) {
-          mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = gconf_client_get_string(gconf_client, "/system/proxy/gopher_host", NULL);
-              pport = gconf_client_get_int(gconf_client, "/system/proxy/gopher_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
-
-        /**
-         * SOCKS:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/socks_host (string)
-         * /system/proxy/socks_port (integer)
-         */
-        if (strcasecmp(cproto, "socks") == 0) {
-          mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = gconf_client_get_string(gconf_client, "/system/proxy/socks_host", NULL);
-              pport = gconf_client_get_int(gconf_client, "/system/proxy/socks_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_socksID);
-          }
-        }
+	if (cproto != NULL) {
+	  /**
+	   * We will have to check protocol by protocol as they do use different
+	   * entries.
+	   */
+	  
+	  use_same_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_same_proxy", NULL);
+	  if (use_same_proxy) {
+	    use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL);
+	    if (use_proxy) {
+	      phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL);
+	      pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL);
+	    }
+	  }
+	  
+	  /**
+	   * HTTP:
+	   * /system/http_proxy/use_http_proxy (boolean)
+	   * /system/http_proxy/host (string)
+	   * /system/http_proxy/port (integer)
+	   */
+	  if (strcasecmp(cproto, "http") == 0) {
+	    use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL);
+	    if (use_proxy) {
+	      if (!use_same_proxy) {
+		phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL);
+		pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL);
+	      }
+	    }
+	  }
+	  
+	  /**
+	   * HTTPS:
+	   * /system/proxy/mode (string) [ "manual" means use proxy settings ]
+	   * /system/proxy/secure_host (string)
+	   * /system/proxy/secure_port (integer)
+	   */
+	  if (strcasecmp(cproto, "https") == 0) {
+	    mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
+	    if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
+	      if (!use_same_proxy) {
+		phost = gconf_client_get_string(gconf_client, "/system/proxy/secure_host", NULL);
+		pport = gconf_client_get_int(gconf_client, "/system/proxy/secure_port", NULL);
+	      }
+	      use_proxy = (phost != NULL);
+	    }
+	  }
+	  
+	  /**
+	   * FTP:
+	   * /system/proxy/mode (string) [ "manual" means use proxy settings ]
+	   * /system/proxy/ftp_host (string)
+	   * /system/proxy/ftp_port (integer)
+	   */
+	  if (strcasecmp(cproto, "ftp") == 0) {
+	    mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
+	    if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
+	      if (!use_same_proxy) {
+		phost = gconf_client_get_string(gconf_client, "/system/proxy/ftp_host", NULL);
+		pport = gconf_client_get_int(gconf_client, "/system/proxy/ftp_port", NULL);
+	      }
+	      use_proxy = (phost != NULL);
+	    }
+	  }
+	  
+	  /**
+	   * GOPHER:
+	   * /system/proxy/mode (string) [ "manual" means use proxy settings ]
+	   * /system/proxy/gopher_host (string)
+	   * /system/proxy/gopher_port (integer)
+	   */
+	  if (strcasecmp(cproto, "gopher") == 0) {
+	    mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
+	    if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
+	      if (!use_same_proxy) {
+		phost = gconf_client_get_string(gconf_client, "/system/proxy/gopher_host", NULL);
+		pport = gconf_client_get_int(gconf_client, "/system/proxy/gopher_port", NULL);
+	      }
+	      use_proxy = (phost != NULL);
+	    }
+	  }
+	  
+	  /**
+	   * SOCKS:
+	   * /system/proxy/mode (string) [ "manual" means use proxy settings ]
+	   * /system/proxy/socks_host (string)
+	   * /system/proxy/socks_port (integer)
+	   */
+	  if (strcasecmp(cproto, "socks") == 0) {
+	    mode =  gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL);
+	    if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
+	      if (!use_same_proxy) {
+		phost = gconf_client_get_string(gconf_client, "/system/proxy/socks_host", NULL);
+		pport = gconf_client_get_int(gconf_client, "/system/proxy/socks_port", NULL);
+	      }
+	      use_proxy = (phost != NULL);
+	    }
+	  }
 
-        if (isCopy == JNI_TRUE)
-          (*env)->ReleaseStringUTFChars(env, proto, cproto);
-
-        if (use_proxy && (phost != NULL)) {
-          jstring jhost;
-          char *noproxyfor;
-          char *s;
-
-          /**
-           * check for the exclude list (aka "No Proxy For" list).
-           * It's a list of comma separated suffixes (e.g. domain name).
-           */
-          noproxyfor = gconf_client_get_string(gconf_client, "/system/proxy/no_proxy_for", NULL);
-          if (noproxyfor != NULL) {
-            char *tmpbuf[512];
-
-            s = strtok_r(noproxyfor, ", ", tmpbuf);
-            urlhost = (*env)->GetStringUTFChars(env, host, &isCopy);
-            if (urlhost != NULL) {
-              while (s != NULL && strlen(s) <= strlen(urlhost)) {
-                if (strcasecmp(urlhost+(strlen(urlhost) - strlen(s)), s) == 0) {
-                  /**
-                   * the URL host name matches with one of the sufixes,
-                   * therefore we have to use a direct connection.
-                   */
-                  use_proxy = 0;
-                  break;
-                }
-                s = strtok_r(NULL, ", ", tmpbuf);
-              }
-              if (isCopy == JNI_TRUE)
-                (*env)->ReleaseStringUTFChars(env, host, urlhost);
-            }
-          }
-          if (use_proxy) {
-            jhost = (*env)->NewStringUTF(env, phost);
-            isa = (*env)->CallStaticObjectMethod(env, isaddr_class, isaddr_createUnresolvedID, jhost, pport);
-            proxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, type_proxy, isa);
-            return proxy;
-          }
-        }
+	}
+	noproxyfor = gconf_client_get_string(gconf_client, "/system/proxy/no_proxy_for", NULL);
+	
+	/**
+	 * check for the exclude list (aka "No Proxy For" list).
+	 * It's a list of comma separated suffixes (e.g. domain name).
+	 */
+	if (noproxyfor != NULL) {
+	  char *tmpbuf[512];
+	  
+	  s = strtok_r(noproxyfor, ", ", tmpbuf);
+	  urlhost = (*env)->GetStringUTFChars(env, host, &isCopy);
+	  if (urlhost != NULL) {
+	    while (s != NULL && strlen(s) <= strlen(urlhost)) {
+	      if (strcasecmp(urlhost+(strlen(urlhost) - strlen(s)), s) == 0) {
+		/**
+		 * the URL host name matches with one of the sufixes,
+		 * therefore we have to use a direct connection.
+		 */
+		use_proxy = 0;
+		break;
+	      }
+	      s = strtok_r(NULL, ", ", tmpbuf);
+	    }
+	    if (isCopy == JNI_TRUE)
+	      (*env)->ReleaseStringUTFChars(env, host, urlhost);
+	  }
+	}
       }
+    } 
+    if (isCopy == JNI_TRUE)
+      (*env)->ReleaseStringUTFChars(env, proto, cproto);
+    g_free (mode);
+    
+    if (use_proxy && (phost != NULL)) {
+      CHECK_NULL(type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID));
+      jhost = (*env)->NewStringUTF(env, phost);
+      isa = (*env)->CallStaticObjectMethod(env, isaddr_class, isaddr_createUnresolvedID, jhost, pport);
+      proxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, type_proxy, isa);
+      g_free (phost);
+      return proxy;
     }
   }
-
-  CHECK_NULL(no_proxy = (*env)->GetStaticObjectField(env, proxy_class, pr_no_proxyID));
-  return no_proxy;
+   
+ CHECK_NULL(no_proxy = (*env)->GetStaticObjectField(env, proxy_class, pr_no_proxyID));
+ return no_proxy;
 }