+2001-03-07 Alex Graveley <alex@ximian.com>
+
+ * src/soup-core/soup-cgi.c: created. moved cgi-related request
+ processing here. do not use it. completely broken.
+
+ * src/soup-core/soup-apache.c: initial commit of Apache module
+ handling, server registration should be performed in a
+ soup_server_init function. Authorization handling still needs to
+ be written.
+
+ * src/soup-core/soup-server.c: cleaned up to have only generic
+ server functions. removed extraneous unregister functions.
+ (soup_server_set_global_auth): set the global server authorize
+ function, to be called in the absence of a method-specific
+ authorize function.
+ (soup_server_set_method_auth): set per-method authorize function.
+
+ * src/soup-core/soup-queue.c (soup_parse_headers): remove unneeded
+ variables.
+
+ * src/soup-core/soup-private.h: add SoupServerHandler,
+ soup_server_get_handler(), and soup_server_authorize().
+
+ * src/soup-wsdl/Makefile.am (INCLUDES): add WSDL_CFLAGS, to get
+ -Werror.
+
+ * src/soup-core/Makefile.am: add new libsoup-apache.so target.
+
+ * soup.spec.in: update and remove hardcoded library version.
+
+ * soup-config.in: add module soup-apache.
+
+ * configure.in: Fix library versioning. Switch version to
+ 0.2.1. Add APACHE_CFLAGS and APACHE_LIBS, gotten from running
+ `apxs`. Remove -Werror from CFLAGS, as apache_conf.h is missing a
+ prototype. Add WSDL_CFLAGS="-Werror" back.
+
+ * TODO (TODO): Updated.
+
2001-03-06 JP Rosevear <jpr@ximian.com>
- * configure.in: properly version the project and give an option to disable more warnings
+ * configure.in: properly version the project and give an option to
+ disable more warnings
2001-03-02 Alex Graveley <alex@ximian.com>
Release stuff:
-* Write apache plugin stuff (soup-server)
+X * Write apache plugin stuff (soup-server)
* Write response code handling stuff, add response userland error
-* clean up configure.in
+X * clean up configure.in
X * fix soup-serializer header file crap.
X * make callback return void? YES. soup_queue_message now takes ownership
-* fix ssl pending bug
+X * fix ssl pending bug
-* fix ssl unsecure error crap
+X * fix ssl unsecure error crap
-* update tests/*
\ No newline at end of file
+X * update tests/*
\ No newline at end of file
AC_INIT(src/soup-core/soup.h)
-SOUP_CURRENT=0
-SOUP_REVISION=2
+SOUP_CURRENT=2
+SOUP_REVISION=0
SOUP_AGE=0
AC_SUBST(SOUP_CURRENT)
AC_SUBST(SOUP_AGE)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(soup, $SOUP_CURRENT.$SOUP_REVISION.$SOUP_AGE)
+AM_INIT_AUTOMAKE(soup, 0.2.1)
AM_MAINTAINER_MODE
enable_debug=$debug_default)
# Set the debug flags
-AC_MSG_CHECKING(for --enable-debug)
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
- AC_MSG_RESULT(yes)
else
if test "x$enable_debug" = "xno"; then
SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
- AC_MSG_RESULT(no)
fi
fi
fi
+AC_PATH_PROG(APXS,apxs,no)
+if test x$APXS != xno; then
+ APACHE_CFLAGS="-I`apxs -q INCLUDEDIR`"
+ APACHE_LIBS=`apxs -q LDFLAGS_SHLIB LIBS_SHLIB`
+
+ save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS=$APACHE_CFLAGS
+ AC_CHECK_HEADERS(httpd.h http_config.h http_core.h http_log.h http_main.h http_protocol.h,
+ [enable_apache="yes"],
+ [enable_apache="no"
+ break])
+ CPPFLAGS=$save_CPPFLAGS
+
+ AC_SUBST(APACHE_CFLAGS)
+ AC_SUBST(APACHE_LIBS)
+fi
+
+
AC_ARG_ENABLE(more-warnings,
-[ --enable-more-warnings Maximum compiler warnings],
-set_more_warnings="$enableval",set_more_warnings=yes)
+ [ --enable-more-warnings Maximum compiler warnings],
+ set_more_warnings="$enableval",
+ set_more_warnings=yes)
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
CFLAGS="$CFLAGS \
-Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes \
- -Wnested-externs -Wpointer-arith -Werror"
+ -Wnested-externs -Wpointer-arith"
+ WSDL_CFLAGS="-Werror"
fi
+AC_SUBST(WSDL_CFLAGS)
+
# Use reentrant functions
CFLAGS="$CFLAGS -D_REENTRANT"
Configuration:
- Source code location: ${srcdir}
- Compiler: ${CC}
- Build flags: ${CFLAGS} ${SOUP_DEBUG_FLAGS}
+ Source code location: ${srcdir}
+ Compiler: ${CC}
+ Build flags: ${CFLAGS} ${SOUP_DEBUG_FLAGS}
+
+ OpenSSL support: ${enable_openssl}
+ Mozilla NSS support: ${enable_nss}
- OpenSSL support: ${enable_openssl}
- Mozilla NSS support: ${enable_nss}
+ Apache module support: ${enable_apache}
"
\ No newline at end of file
-DG_LOG_DOMAIN=\"SOUP\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DBINDIR=\"$(bindir)\" \
- @SOUP_DEBUG_FLAGS@ \
- @GNET_CFLAGS@ \
- @XML_CFLAGS@ \
- @OPENSSL_CFLAGS@ \
- @NSS_CFLAGS@
+ $(SOUP_DEBUG_FLAGS) \
+ $(GNET_CFLAGS) \
+ $(XML_CFLAGS) \
+ $(OPENSSL_CFLAGS) \
+ $(NSS_CFLAGS) \
+ $(APACHE_CFLAGS)
soupincludedir = $(includedir)/soup
-lib_LTLIBRARIES = libsoup.la
+soupinclude_HEADERS = \
+ soup.h \
+ soup-context.h \
+ soup-message.h \
+ soup-misc.h \
+ soup-queue.h \
+ soup-serializer.h \
+ soup-server.h \
+ soup-uri.h
+
+lib_LTLIBRARIES = libsoup.la libsoup-apache.la
libsoup_la_LDFLAGS = -version-info $(SOUP_CURRENT):$(SOUP_REVISION):$(SOUP_AGE)
$(XML_LIBS)
libsoup_la_SOURCES = \
+ soup-cgi.c \
soup-context.c \
soup-headers.h \
soup-headers.c \
soup-ssl.c \
soup-uri.c
-soupinclude_HEADERS = \
- soup.h \
- soup-context.h \
- soup-message.h \
- soup-misc.h \
- soup-queue.h \
- soup-serializer.h \
- soup-server.h \
- soup-uri.h
+libsoup_apache_la_LDFLAGS = \
+ -version-info $(SOUP_CURRENT):$(SOUP_REVISION):$(SOUP_AGE)
+
+libsoup_apache_la_LIBADD = \
+ $(APACHE_LIBS) \
+ -L.libs -lsoup
+
+libsoup_apache_la_SOURCES = \
+ soup-apache.c
bin_PROGRAMS = soup-ssl-proxy
#include "soup-context.h"
#include "soup-queue.h"
+#include "soup-server.h"
#include "soup-uri.h"
#ifdef __cplusplus
gpointer user_data;
};
+typedef struct {
+ gchar *methodname;
+ SoupServerCallbackFn cb;
+ gpointer user_data;
+ SoupServerAuthorizeFn auth_fn;
+ gpointer auth_user_data;
+} SoupServerHandler;
+
/* from soup-message.c */
void soup_message_issue_callback (SoupMessage *req,
gchar *soup_base64_encode (const gchar *text,
gint len);
+/* from soup-server.c */
+
+SoupServerHandler *soup_server_get_handler (const gchar *methodname);
+
+gboolean soup_server_authorize (SoupMessage *msg,
+ gchar *username,
+ gchar *password,
+ gchar *realm);
+
#ifdef __cplusplus
}
#endif
static gboolean
soup_parse_headers (SoupMessage *req)
{
- guint len = req->priv->recv_buf->len;
- gchar *str = req->priv->recv_buf->data;
-
if (req->response_headers)
g_hash_table_destroy (req->response_headers);
req->response_headers = g_hash_table_new (soup_str_case_hash,
soup_str_case_equal);
- if (!soup_headers_parse_response (str,
- len,
+ if (!soup_headers_parse_response (req->priv->recv_buf->data,
+ req->priv->recv_buf->len,
req->response_headers,
&req->response_code,
&req->response_phrase))
#include "soup-headers.h"
#include "soup-private.h"
-static GSList *server_handlers;
-static GMainLoop *server_main;
-static guint server_read_source_tag;
+static GSList *soup_server_handlers = NULL;
-typedef struct {
- gchar *methodname;
- SoupServerCallbackFn cb;
- gpointer user_data;
-} SoupServerHandler;
+static SoupServerAuthorizeFn soup_server_global_auth = NULL;
+static gpointer soup_server_global_auth_user_data = NULL;
+
+SoupServerHandler *
+soup_server_get_handler (const gchar *methodname)
+{
+ GSList *iter = soup_server_handlers;
+
+ g_return_val_if_fail (methodname != NULL, NULL);
+
+ for (iter = soup_server_handlers; iter; iter = iter->next) {
+ SoupServerHandler *hand = iter->data;
+ if (!strcmp (hand->methodname, methodname))
+ return hand;
+ }
+ return NULL;
+}
void
soup_server_register (const gchar *methodname,
SoupServerCallbackFn cb,
gpointer user_data)
{
- SoupServerHandler *hand = g_new0 (SoupServerHandler, 1);
+ SoupServerHandler *hand;
+
+ g_return_if_fail (methodname != NULL);
+
+ hand = g_new0 (SoupServerHandler, 1);
hand->methodname = g_strdup (methodname);
hand->cb = cb;
hand->user_data = user_data;
- server_handlers = g_slist_prepend (server_handlers, hand);
+ soup_server_handlers = g_slist_prepend (soup_server_handlers, hand);
}
-static void
-soup_server_free_handler (SoupServerHandler *hand)
+void
+soup_server_unregister (const gchar *methodname)
{
- server_handlers = g_slist_remove (server_handlers, hand);
+ SoupServerHandler *hand;
+
+ g_return_if_fail (methodname != NULL);
+
+ hand = soup_server_get_handler (methodname);
+ soup_server_handlers = g_slist_remove (soup_server_handlers, hand);
g_free (hand->methodname);
g_free (hand);
}
void
-soup_server_unregister_by_name (const gchar *methodname)
+soup_server_set_global_auth (SoupServerAuthorizeFn cb,
+ gpointer *user_data)
{
- GSList *iter = server_handlers;
- for (iter = server_handlers; iter; iter = iter->next) {
- SoupServerHandler *hand = iter->data;
- if (!strcmp (hand->methodname, methodname))
- soup_server_free_handler (hand);
- }
+ soup_server_global_auth = cb;
+ soup_server_global_auth_user_data = user_data;
}
void
-soup_server_unregister_by_cb (SoupServerCallbackFn cb)
+soup_server_set_method_auth (gchar *methodname,
+ SoupServerAuthorizeFn cb,
+ gpointer *user_data)
{
- GSList *iter = server_handlers;
- for (iter = server_handlers; iter; iter = iter->next) {
- SoupServerHandler *hand = iter->data;
- if (hand->cb == cb) soup_server_free_handler (hand);
- }
-}
+ SoupServerHandler *hand = soup_server_get_handler (methodname);
+ if (!hand) return;
-void
-soup_server_unregister_by_data (gpointer user_data)
-{
- GSList *iter = server_handlers;
- for (iter = server_handlers; iter; iter = iter->next) {
- SoupServerHandler *hand = iter->data;
- if (hand->user_data == user_data)
- soup_server_free_handler (hand);
- }
+ hand->auth_fn = cb;
+ hand->auth_user_data = user_data;
}
-static gboolean
-soup_server_read_cb (GIOChannel *iochannel,
- GIOCondition condition,
- gpointer not_used)
+gboolean
+soup_server_authorize (SoupMessage *msg,
+ gchar *username,
+ gchar *password,
+ gchar *realm)
{
- GSList *iter;
- SoupServerCallbackFn cb = NULL;
- SoupContext *ctx;
- SoupMessage *msg;
- GHashTable *req_headers;
- gchar *req_host, *req_path, *req_method, *resp_phrase, *str, *url;
- gint len, index;
- SoupAction action;
- gpointer user_data;
-
- index = soup_substring_index (str, len, "\r\n\r\n");
- if (!index) goto THROW_MALFORMED_REQUEST;
-
- req_headers = g_hash_table_new (soup_str_case_hash,
- soup_str_case_equal);
-
- if (!soup_headers_parse_request (str,
- index,
- req_headers,
- &req_method,
- &req_path))
- goto THROW_MALFORMED_HEADER;
-
- if ((g_strcasecmp (req_method, "POST") != 0 &&
- g_strcasecmp (req_method, "M-POST") != 0))
- goto THROW_MALFORMED_HEADER;
-
- action = g_hash_table_lookup (req_headers, "SOAPAction");
- if (!action) goto THROW_MALFORMED_HEADER;
-
- for (iter = server_handlers; iter; iter = iter->next) {
- SoupServerHandler *hand = iter->data;
- if (!strcmp (hand->methodname, action)) {
- cb = hand->cb;
- user_data = hand->user_data;
- }
- }
- if (!cb) goto THROW_NO_HANDLER;
-
- req_host = g_hash_table_lookup (req_headers, "Host");
- if (req_host)
- url = g_strconcat ("http://", req_host, req_path, NULL);
- else
- url = g_strdup (req_path);
-
- ctx = soup_context_get (url);
- g_free (url);
-
- /* No Host, no AbsoluteUri */
- if (!ctx) {
- url = g_strconcat ("http://localhost/", req_path, NULL);
- ctx = soup_context_get (url);
- g_free (url);
- }
-
- if (!ctx) goto THROW_MALFORMED_HEADER;
-
- msg = soup_message_new (ctx, action);
-
- msg->action = g_strdup (action);
-
- msg->request.owner = SOUP_BUFFER_SYSTEM_OWNED;
- msg->request.length = len - index - 4;
- msg->request.body = &str [index + 4];
- msg->request_headers = req_headers;
+ SoupServerHandler *hand = soup_server_get_handler (msg->action);
+
+ if (hand && hand->auth_fn)
+ return (hand->auth_fn) (msg,
+ username,
+ password,
+ realm,
+ hand->auth_user_data);
+
+ if (soup_server_global_auth)
+ return (soup_server_global_auth) (msg,
+ username,
+ password,
+ realm,
+ soup_server_global_auth_user_data);
- msg->response_code = 200;
- msg->response_phrase = resp_phrase = g_strdup ("OK");
- msg->response_headers = g_hash_table_new (soup_str_case_hash,
- soup_str_case_equal);
- g_hash_table_insert (msg->response_headers,
- "Content-Type",
- "text/xml\r\n\tcharset=\"utf-8\"");
-
- (*cb) (msg, user_data);
-
- if (msg->response_phrase != resp_phrase) g_free (resp_phrase);
-
- // write msg->response to STDOUT
-
- g_free (req_method);
- g_free (req_path);
- soup_message_free (msg);
-
- THROW_NO_HANDLER:
return TRUE;
-
- THROW_MALFORMED_HEADER:
- g_hash_table_destroy (req_headers);
- g_free (req_method);
- g_free (req_path);
-
- THROW_MALFORMED_REQUEST:
- return TRUE;
-}
-
-static gboolean
-soup_server_error_cb (GIOChannel *iochannel,
- GIOCondition condition,
- gpointer not_used)
-{
- g_source_remove (server_read_source_tag);
- soup_server_main_quit ();
- return FALSE;
-}
-
-void
-soup_server_main (void)
-{
- GIOChannel *chan = g_io_channel_unix_new (STDIN_FILENO);
- server_main = g_main_new (TRUE);
-
- server_read_source_tag = g_io_add_watch (chan,
- G_IO_IN,
- soup_server_read_cb,
- server_handlers);
- g_io_add_watch (chan,
- G_IO_ERR | G_IO_HUP | G_IO_NVAL,
- soup_server_error_cb,
- server_handlers);
-
- g_main_run (server_main);
-}
-
-void
-soup_server_main_quit (void)
-{
- g_return_if_fail (server_main != NULL);
- g_main_quit (server_main);
- server_main = NULL;
}
SoupServerCallbackFn cb,
gpointer user_data);
-void soup_server_unregister_by_name (const gchar *methodname);
+void soup_server_unregister (const gchar *methodname);
-void soup_server_unregister_by_cb (SoupServerCallbackFn cb);
+typedef gboolean (*SoupServerAuthorizeFn) (SoupMessage *msg,
+ gchar *username,
+ gchar *password,
+ gchar *realm,
+ gpointer user_data);
-void soup_server_unregister_by_data (gpointer user_data);
+void soup_server_set_global_auth (SoupServerAuthorizeFn cb,
+ gpointer *user_data);
+
+void soup_server_set_method_auth (gchar *methodname,
+ SoupServerAuthorizeFn cb,
+ gpointer *user_data);
/* CGI Server methods */
typedef void (*SoupServerInit) (void);
+extern SoupServerInit soup_server_init;
+
/* Implement soup_server_init() in your library. */
#endif /* SOUP_SERVER_H */
SoupConnectCallbackFn cb,
gpointer user_data)
{
- SoupSocksData *sd;
+ SoupSocksData *sd = NULL;
SoupContext *proxy_ctx;
SoupUri *dest_uri;
GIOChannel *channel;
SoupUri *soup_uri_new (const gchar* uri_string)
{
SoupUri *g_uri;
- char *semi, *colon, *at, *slash, *path, *query;
+ char *semi, *colon, *at, *slash, *path, *query = NULL;
char **split;
g_uri = g_new (SoupUri,1);
Name: Soup
Description: a SOAP client library in C.
Version: @VERSION@
-Requires: glib, gnet
+Requires: glib
Libs: -L${libdir} -lsoup @GNET_LIBS@ @XML_LIBS@
Cflags: -I${includedir} @GNET_CFLAGS@ @XML_CFLAGS@
\ No newline at end of file