diff options
author | Dan Winship <danw@gnome.org> | 2012-11-06 10:37:54 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-12-11 10:38:22 +0100 |
commit | d834e1e5d8e41f7fa1c082a7ab1ab9ce0335daed (patch) | |
tree | fc78810f7722534d568833e0c03ec457651fdf27 /examples/simple-proxy.c | |
parent | dd3e2f4d9be661a5fae96c81618fb25c438916da (diff) | |
download | libsoup-wip/server.tar.gz |
SoupServer: add exciting new APIs, deprecate musty old oneswip/server
FIXME: server-howto
Diffstat (limited to 'examples/simple-proxy.c')
-rw-r--r-- | examples/simple-proxy.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/examples/simple-proxy.c b/examples/simple-proxy.c index 6623166c..8833257f 100644 --- a/examples/simple-proxy.c +++ b/examples/simple-proxy.c @@ -141,6 +141,8 @@ main (int argc, char **argv) { GOptionContext *opts; GMainLoop *loop; + GSList *uris, *u; + char *str; GError *error = NULL; opts = g_option_context_new (NULL); @@ -152,22 +154,11 @@ main (int argc, char **argv) g_option_context_get_help (opts, TRUE, NULL)); exit (1); } - - if (argc != 2) { - g_printerr ("%s", - g_option_context_get_help (opts, TRUE, NULL)); - exit (1); - } g_option_context_free (opts); signal (SIGINT, quit); - server = soup_server_new (SOUP_SERVER_PORT, port, - NULL); - if (!server) { - g_printerr ("Unable to bind to server port %d\n", port); - exit (1); - } + server = g_object_new (SOUP_TYPE_SERVER, NULL); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); if (require_auth) { @@ -182,9 +173,20 @@ main (int argc, char **argv) g_object_unref (auth_domain); } - g_print ("\nStarting proxy on port %d\n", - soup_server_get_port (server)); - soup_server_run_async (server); + soup_server_listen_all (server, port, 0, &error); + if (error) { + g_printerr ("Unable to create server: %s\n", error->message); + exit (1); + } + + uris = soup_server_get_uris (server); + for (u = uris; u; u = u->next) { + str = soup_uri_to_string (u->data, FALSE); + g_print ("Listening on %s\n", str); + g_free (str); + soup_uri_free (u->data); + } + g_slist_free (uris); session = soup_session_async_new (); |