summaryrefslogtreecommitdiff
path: root/libsoup/soup-server.c
diff options
context:
space:
mode:
authorAlex Graveley <alex@ximian.com>2002-03-21 03:57:59 +0000
committerAlex Graveley <orph@src.gnome.org>2002-03-21 03:57:59 +0000
commit415fea22b868868f0e4b84af41f9ea886d510bdb (patch)
treeb2d1e2f5c951a5111ac1a0e367854dfbca348953 /libsoup/soup-server.c
parentc4f004f7dba3792386a0c034a3a89519f8d3eac7 (diff)
downloadlibsoup-415fea22b868868f0e4b84af41f9ea886d510bdb.tar.gz
Return default handler if none exist. Unregister default handler before
2002-03-20 Alex Graveley <alex@ximian.com> * src/libsoup/soup-server.c (soup_server_get_handler): Return default handler if none exist. Unregister default handler before resetting. (soup_server_register): Break out auth copying. (auth_context_copy): To here.
Diffstat (limited to 'libsoup/soup-server.c')
-rw-r--r--libsoup/soup-server.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 6b6087dd..5f2f4c81 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -1130,12 +1130,9 @@ soup_server_get_handler (SoupServer *server, const gchar *path)
g_return_val_if_fail (server != NULL, NULL);
- if (!path)
+ if (!path || !server->handlers)
return server->default_handler;
- if (!server->handlers)
- return NULL;
-
mypath = g_strdup (path);
dir = strchr (mypath, '?');
@@ -1159,6 +1156,28 @@ soup_server_get_handler (SoupServer *server, const gchar *path)
return server->default_handler;
}
+static SoupServerAuthContext *
+auth_context_copy (SoupServerAuthContext *auth_ctx)
+{
+ SoupServerAuthContext *new_auth_ctx = NULL;
+
+ new_auth_ctx = g_new0 (SoupServerAuthContext, 1);
+
+ new_auth_ctx->types = auth_ctx->types;
+ new_auth_ctx->callback = auth_ctx->callback;
+ new_auth_ctx->user_data = auth_ctx->user_data;
+
+ new_auth_ctx->basic_info.realm =
+ g_strdup (auth_ctx->basic_info.realm);
+
+ new_auth_ctx->digest_info.realm =
+ g_strdup (auth_ctx->digest_info.realm);
+ new_auth_ctx->digest_info.allow_algorithms =
+ auth_ctx->digest_info.allow_algorithms;
+ new_auth_ctx->digest_info.force_integrity =
+ auth_ctx->digest_info.force_integrity;
+}
+
void
soup_server_register (SoupServer *server,
const gchar *path,
@@ -1173,23 +1192,8 @@ soup_server_register (SoupServer *server,
g_return_if_fail (server != NULL);
g_return_if_fail (callback != NULL);
- if (auth_ctx) {
- new_auth_ctx = g_new0 (SoupServerAuthContext, 1);
-
- new_auth_ctx->types = auth_ctx->types;
- new_auth_ctx->callback = auth_ctx->callback;
- new_auth_ctx->user_data = auth_ctx->user_data;
-
- new_auth_ctx->basic_info.realm =
- g_strdup (auth_ctx->basic_info.realm);
-
- new_auth_ctx->digest_info.realm =
- g_strdup (auth_ctx->digest_info.realm);
- new_auth_ctx->digest_info.allow_algorithms =
- auth_ctx->digest_info.allow_algorithms;
- new_auth_ctx->digest_info.force_integrity =
- auth_ctx->digest_info.force_integrity;
- }
+ if (auth_ctx)
+ new_auth_ctx = auth_context_copy (auth_ctx);
new_hand = g_new0 (SoupServerHandler, 1);
new_hand->path = g_strdup (path);
@@ -1208,8 +1212,10 @@ soup_server_register (SoupServer *server,
g_hash_table_insert (server->handlers,
(gchar *) new_hand->path,
new_hand);
- } else
+ } else {
+ soup_server_unregister (server, NULL);
server->default_handler = new_hand;
+ }
}
void
@@ -1227,7 +1233,8 @@ soup_server_unregister (SoupServer *server, const gchar *path)
return;
}
- if (!server->handlers) return;
+ if (!server->handlers)
+ return;
hand = g_hash_table_lookup (server->handlers, path);
if (hand) {