[Xfce4-commits] <midori:master> Use Midori.URI API in sokoke_prefetch_uri

Christian Dywan noreply at xfce.org
Sat Oct 29 00:46:02 CEST 2011


Updating branch refs/heads/master
         to d39b62c73e83fa016b72f1d0567739b9ab9c39ea (commit)
       from cebf09e804c1cc61abad897993e254e02f70ce30 (commit)

commit d39b62c73e83fa016b72f1d0567739b9ab9c39ea
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Oct 29 00:43:03 2011 +0200

    Use Midori.URI API in sokoke_prefetch_uri

 midori/sokoke.c |   30 ++++++++++--------------------
 1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/midori/sokoke.c b/midori/sokoke.c
index 3dfb7e5..69ca982 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1546,38 +1546,28 @@ sokoke_prefetch_uri (MidoriWebSettings*  settings,
     #define MAXHOSTS 50
     static gchar* hosts = NULL;
     static gint host_count = G_MAXINT;
-
-    SoupURI* s_uri;
-
-    if (!uri)
-        return FALSE;
+    gchar* hostname;
 
     if (settings && !katze_object_get_boolean (settings, "enable-dns-prefetching"))
         return FALSE;
 
-    s_uri = soup_uri_new (uri);
-    if (!s_uri || !s_uri->host)
-        return FALSE;
-
-    if (g_hostname_is_ip_address (s_uri->host))
-    {
-        soup_uri_free (s_uri);
-        return FALSE;
-    }
-    if (!g_str_has_prefix (uri, "http"))
+    if (!(hostname = midori_uri_parse (uri, NULL))
+     || !strcmp (hostname, uri)
+     || g_hostname_is_ip_address (hostname)
+     || !midori_uri_is_http (uri))
     {
-        soup_uri_free (s_uri);
+        g_free (hostname);
         return FALSE;
     }
 
     if (!hosts ||
-        !g_regex_match_simple (s_uri->host, hosts,
+        !g_regex_match_simple (hostname, hosts,
                                G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
     {
         SoupAddress* address;
         gchar* new_hosts;
 
-        address = soup_address_new (s_uri->host, SOUP_ADDRESS_ANY_PORT);
+        address = soup_address_new (hostname, SOUP_ADDRESS_ANY_PORT);
         soup_address_resolve_async (address, 0, 0, callback, user_data);
         g_object_unref (address);
 
@@ -1587,12 +1577,12 @@ sokoke_prefetch_uri (MidoriWebSettings*  settings,
             host_count = 0;
         }
         host_count++;
-        new_hosts = g_strdup_printf ("%s|%s", hosts, s_uri->host);
+        new_hosts = g_strdup_printf ("%s|%s", hosts, hostname);
         katze_assign (hosts, new_hosts);
     }
     else if (callback)
         callback (NULL, SOUP_STATUS_OK, user_data);
-    soup_uri_free (s_uri);
+    g_free (hostname);
     return TRUE;
 }
 


More information about the Xfce4-commits mailing list