diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2011-05-08 17:51:39 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2011-05-08 17:51:39 -0700 |
commit | 5491de0482cfdf3dcdbbecd03c07f22a0767e73d (patch) | |
tree | 9133133dec9be2dd79ac89e7c2ab2ac9784054e2 /tools/wispr.c | |
parent | 0c07cbad2ee8450fbe8050bf6223a99e3f2e01a9 (diff) | |
download | connman-5491de0482cfdf3dcdbbecd03c07f22a0767e73d.tar.gz connman-5491de0482cfdf3dcdbbecd03c07f22a0767e73d.tar.bz2 connman-5491de0482cfdf3dcdbbecd03c07f22a0767e73d.zip |
tools: Add support for broken WISPr responses
Some hotspots answer with 404 or 200 responses, but are still in login
stage. If the WISPr XML strings are found, treat all status results the
same to trigger login procedure.
Diffstat (limited to 'tools/wispr.c')
-rw-r--r-- | tools/wispr.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/tools/wispr.c b/tools/wispr.c index 7de9dbb0..a0002ba3 100644 --- a/tools/wispr.c +++ b/tools/wispr.c @@ -530,7 +530,10 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data) printf("Logoff URL: %s\n", wispr->msg.logoff_url); printf("\n"); - if (status == 302 && wispr->msg.message_type == 100) { + if (status != 200 && status != 302 && status != 404) + goto done; + + if (wispr->msg.message_type == 100) { if (wispr->username == NULL) { user_input("Username", FALSE, username_callback, wispr); return FALSE; @@ -543,13 +546,30 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data) g_idle_add(execute_login, wispr); return FALSE; - } else if (status == 200 && (wispr->msg.message_type == 120 || - wispr->msg.message_type == 140)) { + } else if (wispr->msg.message_type == 120 || + wispr->msg.message_type == 140) { int code = wispr->msg.response_code; printf("Login process: %s\n", code == 50 ? "SUCCESS" : "FAILURE"); } + if (status == 302) { + const char *redirect; + + if (g_web_result_get_header(result, "Location", + &redirect) == FALSE) + goto done; + + printf("\n"); + printf("Redirect URL: %s\n", redirect); + printf("\n"); + + wispr->request = g_web_request_get(wispr->web, redirect, + wispr_result, wispr); + + return FALSE; + } + done: g_main_loop_quit(main_loop); |