]> sjero.net Git - wget/commitdiff
Improve output in case of --post-{file,body} commands.
authorDarshit Shah <darnir@gmail.com>
Wed, 24 Apr 2013 04:54:01 +0000 (10:24 +0530)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Wed, 24 Apr 2013 19:08:33 +0000 (21:08 +0200)
src/ChangeLog
src/http.c
src/main.c

index 64fc6342a18b9f523b49857a7ca82353aa858ac2..e9572051cd573c6e832cca58ebdf3a5907e74ccb 100644 (file)
@@ -1,3 +1,10 @@
+2013-04-24  Darshit Shah <darnir@gmail.com>
+
+       * http.c (gethttp): Remove check for opt.post_data and
+       opt.post_file_name.
+       * main.c (main): Change location in code where --post-data and
+       --post-file options are converted to --body-data --body-file.
+
 2013-04-21  Gijs van Tulder  <gvtulder@gmail.com>
 
        * http.c: Copy opt.body_data to the WARC file, instead of
 2013-04-21  Gijs van Tulder  <gvtulder@gmail.com>
 
        * http.c: Copy opt.body_data to the WARC file, instead of
index 88f7a96fd1a39ea98bee2aa19fd3e3760aa6730e..25ad4740f8c35f2419a77d2e2648550162879ce0 100644 (file)
@@ -1765,8 +1765,6 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
     const char *meth = "GET";
     if (head_only)
       meth = "HEAD";
     const char *meth = "GET";
     if (head_only)
       meth = "HEAD";
-    else if (opt.post_file_name || opt.post_data)
-      meth = "POST";
     else if (opt.method)
       {
         char *q;
     else if (opt.method)
       {
         char *q;
index d2e7d040cbc6d34b71d234c3e8d23c91a19eb572..2b42d2d7235eda6c1d7295b974423a6bb13c1084 100644 (file)
@@ -1220,20 +1220,6 @@ main (int argc, char **argv)
   if (opt.verbose == -1)
     opt.verbose = !opt.quiet;
 
   if (opt.verbose == -1)
     opt.verbose = !opt.quiet;
 
-  if (opt.post_data || opt.post_file_name)
-    {
-        setoptval ("method", "POST", "method");
-        if (opt.post_data)
-          {
-            setoptval ("bodydata", opt.post_data, "body-data");
-            opt.post_data = NULL;
-          }
-        else
-          {
-            setoptval ("bodyfile", opt.post_file_name, "body-file");
-            opt.post_file_name = NULL;
-          }
-    }
 
   /* Sanity checks.  */
   if (opt.verbose && opt.quiet)
 
   /* Sanity checks.  */
   if (opt.verbose && opt.quiet)
@@ -1411,6 +1397,29 @@ for details.\n\n"));
         }
     }
 
         }
     }
 
+  /* Convert post_data to body-data and post_file_name to body-file options.
+     This is required so as to remove redundant code later on in gethttp().
+     The --post-data and --post-file options may also be removed in
+     the future hence it makes sense to convert them to aliases for
+     the more generic --method options.
+     This MUST occur only after the sanity checks so as to prevent the
+     user from setting both post and body options simultaneously.
+  */
+  if (opt.post_data || opt.post_file_name)
+    {
+        setoptval ("method", "POST", "method");
+        if (opt.post_data)
+          {
+            setoptval ("bodydata", opt.post_data, "body-data");
+            opt.post_data = NULL;
+          }
+        else
+          {
+            setoptval ("bodyfile", opt.post_file_name, "body-file");
+            opt.post_file_name = NULL;
+          }
+    }
+
 #ifdef ENABLE_IRI
   if (opt.enable_iri)
     {
 #ifdef ENABLE_IRI
   if (opt.enable_iri)
     {