[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Syntax for RESTful scripting options
From: |
Darshit Shah |
Subject: |
Re: [Bug-wget] Syntax for RESTful scripting options |
Date: |
Sun, 7 Apr 2013 02:02:06 +0530 |
> > + if (opt.method)
> > + {
> > + request_set_header (req, "Content-Type",
> > + "application/x-www-form-urlencoded",
> rel_none);
> > +
> > + if (opt.body_data || opt.body_file)
> > + {
>
> please indent '{' with two empty spaces.
>
Sorry, still not completely used to GNU's indentation method. I sometimes
slip up and forget that indent.
Currently mobile, I'll make the change as soon as I get access to a
machine.
> > + if (opt.body_data)
> > + body_data_size = strlen (opt.body_data);
> > + else
> > + {
> > + body_data_size = file_size (opt.body_file);
> > + if (body_data_size == -1)
> > + {
> > + logprintf (LOG_NOTQUIET, _("BODY data file %s missing:
> %s\n"),
> > + quote (opt.body_file), strerror (errno));
> > + return FILEBADFILE;
> > + }
> > + }
> > + request_set_header (req, "Content-Length",
> > + xstrdup (number_to_static_string
> (body_data_size)),
> > + rel_value);
> > + }
> > + }
> > +
>
> maybe the previous "if (opt.post_data || opt.post_file_name)" case can
> be handled here?
>
> What will break if we just do:
>
> if (opt.post_data || opt.post_file_name)
> {
> opt.method = "POST";
> opt.body_data = opt.post_data;
> opt.body_file = opt.post_file;
> }
>
> before you check for if (opt.method)?
>
> Do you think we can get ride of the old code to handle POST data?
>
That would be possible, if we set opt.post_data and opt.post_file_name as
aliases to set opt.method="POST" and opt.body_data or opt.body_file in
main.c
Otherwise, this will cause some inconsistent output, wherein in one place
it says Post-Data and in another wget outputs Body-Data.
That can however be avoided, if the line reads:
logprintf (LOG_NOTQUIET, _("%s data file %s missing: %s\n"),
quote (opt.method), quote (opt.body_file),
strerror (errno));
However, since the code is explicitly checking for opt.method and
opt.post_data / opt.post_file_name in multiple places, this has a very high
chance of breaking if the server redirects.
I'll run some tests after the change and let you know.
> In any case I can't still apply your patch upstream, I am waiting for
> your copyright assignment papers to be processed (or received).
>
I have already sent the papers by snail mail. Wish there was a way to
submit them electronically.
--
Thanking You,
Darshit Shah
Research Lead, Code Innovation
Kill Code Phobia.
B.E.(Hons.) Mechanical Engineering, '14. BITS-Pilani