Re: httpd question (newbie)
Joe Shaw <[email protected]> 01 Oct 2002 14:50:03 -0400
| Newsgroups | gmane.comp.gnome.ximian.soup |
|---|---|
| Message-ID | <1033498203.4981.33.camel@caedes> |
On Tue, 2002-10-01 at 07:10, Reboot Now wrote:
> Hi there.
> Having just started looking into soup this week I have
> a question. Is it possible to use soup-httpd or
> soap-server as a normal http server so that you can
> connect to it with a browser?
> At this stage it seems to me that you have to use it
> with apache, which I don't want to do. I just want a
> small stand alone server and if the soup library can
> be used for this it would be great. Google only give
> me a few discussion on this list about this subject,
> and even they aren't very clear. Could someone please
> point me in the right direction or maybe have some
> example code?
Yep. We're using it as a standalone server. Make sure you use the
soup-0-7 branch, as that's the latest from CVS.
Here's some hastily-written sample code:
int
main () {
GMainLoop *main_loop;
SoupServer *server;
main_loop = g_main_loop_new (NULL, TRUE);
server = soup_server_new (SOUP_PROTOCOL_HTTP, 8080);
if (!server) {
/* couldn't bind to the port... */
exit (-1);
}
soup_server_register (server, "/foo", NULL, foo_callback, NULL, NULL);
soup_server_register (server, NULL, NULL, default_callback, NULL, NULL);
soup_server_run_async (server);
g_main_loop_run (main_loop);
}
static void
foo_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
{
msg->response.owner = SOUP_BUFFER_STATIC;
msg->response.body = "<html><body><b><blink>Hello world</blink></b></body></html>";
msg->response.length = strlen (msg->response.body);
soup_message_set_error (msg, SOUP_ERROR_OK);
}
static void
default_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
{
soup_message_set_error (msg, SOUP_ERROR_NOT_FOUND);
}
_______________________________________________
Soup-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/soup-list