use the redirect function in the example code
[project/uclient.git] / uclient-example.c
index 07b330d..c8f0b1b 100644 (file)
@@ -9,7 +9,7 @@ static void example_header_done(struct uclient *cl)
        struct blob_attr *cur;
        int rem;
 
-       printf("Headers: \n");
+       printf("Headers (%d): \n", cl->status_code);
        blobmsg_for_each_attr(cur, cl->meta, rem) {
                printf("%s=%s\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
        }
@@ -55,6 +55,14 @@ static void example_request_sm(struct uclient *cl)
 
 static void example_eof(struct uclient *cl)
 {
+       static int retries;
+
+       if (retries < 10 && uclient_http_redirect(cl)) {
+               retries++;
+               return;
+       }
+
+       retries = 0;
        example_request_sm(cl);
 }