diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 5ed4fb7..14c244f 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1738,6 +1738,44 @@ soup_session_abort (SoupSession *session)
 	g_slist_free (conns);
 }
 
+static void
+dns_prefetch (SoupSession *session, SoupURI *uri)
+{
+	SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
+	SoupSessionHost *host;
+	SoupAddress *addr;
+
+	g_mutex_lock (priv->host_lock);
+	host = get_host_for_uri (session, uri);
+	addr = g_object_ref (host->addr);
+	g_mutex_unlock (priv->host_lock);
+
+	soup_address_resolve_async (addr, priv->async_context,
+				    NULL, NULL, NULL);
+}
+
+static void
+soup_session_prepare_for_uri_proxy_cb (SoupProxyURIResolver *resolver, guint status,
+				       SoupURI *proxy_uri, gpointer user_data)
+{
+	SoupSession *session;
+	SoupSessionPrivate *priv;
+	SoupURI *uri;
+	gpointer *data = user_data;
+
+	session = data[0];
+	uri = data[1];
+	g_slice_free1 (2*sizeof(gpointer), data);
+	priv = SOUP_SESSION_GET_PRIVATE (session);
+
+	if (proxy_uri) {
+		dns_prefetch (session, proxy_uri);
+	} else {
+		dns_prefetch (session, uri);
+	}
+	soup_uri_free (uri);
+}
+
 /**
 * soup_session_prepare_for_uri:
 * @session: a #SoupSession
@@ -1758,16 +1796,21 @@ void
 soup_session_prepare_for_uri (SoupSession *session, SoupURI *uri)
 {
 	SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
-	SoupSessionHost *host;
-	SoupAddress *addr;
-
-	g_mutex_lock (priv->host_lock);
-	host = get_host_for_uri (session, uri);
-	addr = g_object_ref (host->addr);
-	g_mutex_unlock (priv->host_lock);
-
-	soup_address_resolve_async (addr, priv->async_context,
-				    NULL, NULL, NULL);
+	gpointer *udata;
+	SoupProxyURIResolver *proxy_uri_resolver;
+
+	proxy_uri_resolver = SOUP_PROXY_URI_RESOLVER (soup_session_get_feature (session, SOUP_TYPE_PROXY_URI_RESOLVER));
+
+	if (proxy_uri_resolver != NULL) {
+		udata = g_slice_alloc(2*sizeof(gpointer));
+		udata[0] = session;
+		udata[1] = soup_uri_copy(uri);
+		soup_proxy_uri_resolver_get_proxy_uri_async (proxy_uri_resolver, uri, priv->async_context,
+							     NULL, soup_session_prepare_for_uri_proxy_cb,
+							     udata);
+	} else {
+		dns_prefetch (session, uri);
+	}
 }
 
 /**
