summaryrefslogtreecommitdiff
path: root/examples/simple-proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simple-proxy.c')
-rw-r--r--examples/simple-proxy.c32
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 ();