X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fmain.c;fp=src%2Fmain.c;h=2b42d2d7235eda6c1d7295b974423a6bb13c1084;hp=d2e7d040cbc6d34b71d234c3e8d23c91a19eb572;hb=54fd8de415cd31e015cf3a391818d3c83fce21c6;hpb=81409cb9c8eb3b6d22fdbf31708ebcab6cfa0ea2 diff --git a/src/main.c b/src/main.c index d2e7d040..2b42d2d7 100644 --- a/src/main.c +++ b/src/main.c @@ -1220,20 +1220,6 @@ main (int argc, char **argv) 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) @@ -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) {