Allow max HTTP redirects to be controlled YAZ-667
[yaz-moved-to-github.git] / util / yaz-url.c
index 498e2f8..54551dd 100644 (file)
@@ -21,6 +21,7 @@ static void usage(void)
     printf(" -m method           Sets HTTP method\n");
     printf(" -O fname            Writes HTTP content to file\n");
     printf(" -p fname            POSTs file at following url\n");
+    printf(" -R num              Set maximum number of HTTP redirects\n");
     printf(" -u user/password    Sets Basic HTTP auth\n");
     printf(" -x proxy            Sets HTTP proxy\n");
     exit(1);
@@ -72,7 +73,7 @@ int main(int argc, char **argv)
     int no_urls = 0;
     const char *outfname = 0;
 
-    while ((ret = options("hH:m:O:p:u:x:", argv, argc, &arg))
+    while ((ret = options("h{help}H:m:O:p:R{max-redirs}:u:x:", argv, argc, &arg))
            != YAZ_OPTIONS_EOF)
     {
         switch (ret)
@@ -109,6 +110,9 @@ int main(int argc, char **argv)
             post_buf = get_file(arg, &post_len);
             method = "POST";
             break;
+        case 'R':
+            yaz_url_set_max_redirects(p, atoi(arg));
+            break;
         case 'u':
             if (strchr(arg, '/'))
             {