From: Mohamed Abbas <mab...@linux.intel.com>

Support new GWeb format.
---
 tools/web-test.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/tools/web-test.c b/tools/web-test.c
index 253948f..3f88a2d 100644
--- a/tools/web-test.c
+++ b/tools/web-test.c
@@ -34,6 +34,8 @@ static GTimer *timer;
 
 static GMainLoop *main_loop;
 
+static GString *content;
+
 static void web_debug(const char *str, void *data)
 {
        g_print("%s: %s\n", (const char *) data, str);
@@ -50,6 +52,7 @@ static void web_result(uint16_t status, gpointer user_data)
 
        elapsed = g_timer_elapsed(timer, NULL);
 
+       g_print("%s", content->str);
        g_print("elapse: %f seconds\n", elapsed);
 
        g_print("status: %03u\n", status);
@@ -57,6 +60,14 @@ static void web_result(uint16_t status, gpointer user_data)
        g_main_loop_quit(main_loop);
 }
 
+static gboolean received_data(const unsigned char *str, int len,
+                                               GWebDataType data_type,
+                                               gpointer user_data)
+{
+       g_string_append_len(content, (gchar *)str, len);
+       return TRUE;
+}
+
 static gboolean option_debug = FALSE;
 static gchar *option_nameserver = NULL;
 
@@ -95,6 +106,12 @@ int main(int argc, char *argv[])
                return 1;
        }
 
+       content = g_string_sized_new(1024);
+       if (content == NULL) {
+               printf("failed to allocate buf\n");
+               return 1;
+       }
+
        web = g_web_new(index);
        if (web == NULL) {
                printf("failed to web service\n");
@@ -114,7 +131,7 @@ int main(int argc, char *argv[])
        timer = g_timer_new();
 
        if (g_web_request(web, G_WEB_METHOD_GET, argv[1],
-                                       web_result, NULL) == 0) {
+                               received_data, web_result, NULL) == 0) {
                printf("failed to start request\n");
                return 1;
        }
@@ -130,6 +147,8 @@ int main(int argc, char *argv[])
 
        g_web_unref(web);
 
+       g_string_free(content, TRUE);
+
        g_main_loop_unref(main_loop);
 
        return 0;
-- 
1.7.2.3

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to