[libsoup] soup_auth_domain_covers: skip the URI path check with proxy auth domains



commit 1a810a4f2f0c5ea6739c7fc6b3278485057c50af
Author: Dan Winship <danw gnome org>
Date:   Sat Apr 10 11:55:16 2010 -0400

    soup_auth_domain_covers: skip the URI path check with proxy auth domains
    
    also, add proxy auth support to tests/simple-proxy

 libsoup/soup-auth-domain.c |    8 +++++---
 tests/simple-proxy.c       |   26 +++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/libsoup/soup-auth-domain.c b/libsoup/soup-auth-domain.c
index 62fa772..18b7ad4 100644
--- a/libsoup/soup-auth-domain.c
+++ b/libsoup/soup-auth-domain.c
@@ -553,9 +553,11 @@ soup_auth_domain_covers (SoupAuthDomain *domain, SoupMessage *msg)
 	SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
 	const char *path;
 
-	path = soup_message_get_uri (msg)->path;
-	if (!soup_path_map_lookup (priv->paths, path))
-		return FALSE;
+	if (!priv->proxy) {
+		path = soup_message_get_uri (msg)->path;
+		if (!soup_path_map_lookup (priv->paths, path))
+			return FALSE;
+	}
 
 	if (priv->filter && !priv->filter (domain, msg, priv->filter_data))
 		return FALSE;
diff --git a/tests/simple-proxy.c b/tests/simple-proxy.c
index 117c3ff..0101b63 100644
--- a/tests/simple-proxy.c
+++ b/tests/simple-proxy.c
@@ -14,10 +14,7 @@
 #include <unistd.h>
 
 #include <glib.h>
-#include <libsoup/soup-address.h>
-#include <libsoup/soup-message.h>
-#include <libsoup/soup-server.h>
-#include <libsoup/soup-session-async.h>
+#include <libsoup/soup.h>
 
 /* WARNING: this is really really really not especially compliant with
  * RFC 2616. But it does work for basic stuff.
@@ -120,6 +117,13 @@ server_callback (SoupServer *server, SoupMessage *msg,
 	soup_server_pause_message (server, msg);
 }
 
+static gboolean
+auth_callback (SoupAuthDomain *auth_domain, SoupMessage *msg,
+	       const char *username, const char *password, gpointer data)
+{
+	return !strcmp (username, "user") && !strcmp (password, "password");
+}
+
 static void
 quit (int sig)
 {
@@ -133,13 +137,21 @@ main (int argc, char **argv)
 	GMainLoop *loop;
 	int opt;
 	int port = SOUP_ADDRESS_ANY_PORT;
+	SoupAuthDomain *auth_domain = NULL;
 
 	g_thread_init (NULL);
 	g_type_init ();
 	signal (SIGINT, quit);
 
-	while ((opt = getopt (argc, argv, "p:s:")) != -1) {
+	while ((opt = getopt (argc, argv, "ap:")) != -1) {
 		switch (opt) {
+		case 'a':
+			auth_domain = soup_auth_domain_basic_new (
+				SOUP_AUTH_DOMAIN_REALM, "simple-proxy",
+				SOUP_AUTH_DOMAIN_PROXY, TRUE,
+				SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, auth_callback,
+				NULL);
+			break;
 		case 'p':
 			port = atoi (optarg);
 			break;
@@ -158,6 +170,10 @@ main (int argc, char **argv)
 	}
 	soup_server_add_handler (server, NULL,
 				 server_callback, NULL, NULL);
+	if (auth_domain) {
+		soup_server_add_auth_domain (server, auth_domain);
+		g_object_unref (auth_domain);
+	}
 
 	printf ("\nStarting proxy on port %d\n",
 		soup_server_get_port (server));



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