--- soup-proxy-resolver-gnome.c	2009-05-18 21:43:20.000000000 +0800
+++ /root/soup-proxy-resolver-gnome.c	2009-07-21 22:08:47.892836393 +0800
@@ -37,6 +37,8 @@
 G_LOCK_DEFINE_STATIC (resolver_gnome);
 static SoupProxyResolverGNOMEMode proxy_mode;
 static GConfClient *gconf_client;
+static char *proxy_username;
+static char *proxy_password;
 
 static pxProxyFactory *libproxy_factory;
 static GThreadPool *libproxy_threadpool;
@@ -159,6 +161,8 @@
 #define SOUP_GCONF_PROXY_AUTOCONFIG_URL "/system/proxy/autoconfig_url"
 #define SOUP_GCONF_HTTP_PROXY_HOST      "/system/http_proxy/host"
 #define SOUP_GCONF_HTTP_PROXY_PORT      "/system/http_proxy/port"
+#define SOUP_GCONF_HTTP_PROXY_USERNAME  "/system/http_proxy/authentication_user"
+#define SOUP_GCONF_HTTP_PROXY_PASSWORD  "/system/http_proxy/authentication_password"
 #define SOUP_GCONF_HTTPS_PROXY_HOST     "/system/proxy/secure_host"
 #define SOUP_GCONF_HTTPS_PROXY_PORT     "/system/proxy/secure_port"
 #define SOUP_GCONF_USE_SAME_PROXY       "/system/http_proxy/use_same_proxy"
@@ -186,6 +190,16 @@
 					    (int *)&proxy_mode))
 		proxy_mode = SOUP_PROXY_RESOLVER_GNOME_MODE_NONE;
 	g_free (mode);
+	if (proxy_username) {
+		g_free (proxy_username);
+	}
+	proxy_username = gconf_client_get_string (
+				gconf_client, SOUP_GCONF_HTTP_PROXY_USERNAME, NULL);
+	if (proxy_password) {
+		g_free (proxy_password);
+	}
+	proxy_password = gconf_client_get_string (
+				gconf_client, SOUP_GCONF_HTTP_PROXY_PASSWORD, NULL);
 
 	if (proxy_mode == SOUP_PROXY_RESOLVER_GNOME_MODE_NONE) {
 		if (libproxy_factory) {
@@ -405,6 +419,20 @@
 }
 
 static void
+set_proxy_auth (SoupMessage         *msg)
+{
+	if (proxy_username && proxy_password) {
+		char *userpass = g_strdup_printf ("%s:%s", proxy_username, proxy_password);
+		char *token = g_base64_encode ((unsigned char *)userpass, strlen(userpass));
+		char *header = g_strdup_printf ("Basic %s", token);
+		soup_message_headers_replace (msg->request_headers, "Proxy-Authorization", header);
+		g_free (userpass);
+		g_free (token);
+		g_free (header);
+	}
+}
+
+static void
 get_proxy_async (SoupProxyResolver  *proxy_resolver,
 		 SoupMessage        *msg,
 		 GMainContext       *async_context,
@@ -445,6 +473,10 @@
 	G_UNLOCK (resolver_gnome);
 
 	if (sgad->addr) {
+		set_proxy_auth(msg);
+	}
+
+	if (sgad->addr) {
 		soup_address_resolve_async (sgad->addr, async_context,
 					    cancellable, resolved_address,
 					    sgad);
@@ -464,8 +496,12 @@
 	if (proxy_mode == SOUP_PROXY_RESOLVER_GNOME_MODE_NONE) {
 		*addr = NULL;
 		status = SOUP_STATUS_OK;
-	} else
+	} else {
 		status = get_proxy_for_message (msg, addr);
+		if (addr) {
+			set_proxy_auth(msg);
+		}
+	}
 	G_UNLOCK (resolver_gnome);
 
 	if (!*addr || status != SOUP_STATUS_OK)
