#include <glib.h>
#include <libsoup/soup.h>

static void
message_callback (SoupSession *session,
                  SoupMessage *message,
                  gpointer user_data)
{
    if (SOUP_STATUS_IS_SUCCESSFUL (message->status_code))
        g_print ("ok\n");
    else
        g_print ("not ok\n");
}

static void
enqueue_message (SoupSession *session)
{
    SoupMessage *message;

    message = soup_message_new ("GET", "http://people.gnome.org/~csaavedra/index.html");
    soup_session_queue_message (session,
                                message,
                                message_callback,
                                NULL);
}

int main ()
{
    g_type_init ();
    GMainLoop *loop;

    SoupSession *session = soup_session_async_new ();

    loop = g_main_loop_new (NULL, TRUE);

    enqueue_message (session);
    g_main_context_iteration (g_main_loop_get_context (loop), FALSE);

    g_object_set (session, "proxy-uri", NULL, NULL);
    g_main_context_iteration (g_main_loop_get_context (loop), FALSE);

    enqueue_message (session);

    g_main_loop_run (loop);

    return 0;
}
