Re: [Bug-wget] Syntax for RESTful scripting options

2013-03-08 Thread Darshit Shah
Okay gathering inputs from all the replies above., I think the best way to
move forward would be to implement a --method=
followed by --post-data or --post-file in case of POST and --put-data
--put-file in case of the PUT option.
In other cases wget expects the URL next.
The GET option is included only for completeness.

Please do let me know if I'm missing something.

Also, as Tim pointed out, wget does not test whether the file exists. I'll
patch that too.

On Fri, Mar 8, 2013 at 5:12 AM, Hrvoje Niksic  wrote:

> Tim Ruehsen  writes:
>
> > BTW:
> > How can Wget create a POST without any data (without Content-Type and
> Content-
> > Length) ? Curl can...
>
> If by "without any data" you mean with empty POST data, use
> `--post-data=""'.  But that will send 0 Content-Length and the usual
> Content-Type.  As always, you can customize both headers using the
> `--header' option, but I don't think you can remove them entirely.
>
> Maybe the `--header' syntax could be extended so that `--header=NAME'
> (note lack of trailing colon -- currently illegal) could be used to
> delete the generated header from the HTTP request.
>
> > resulting request:
> > POST /xxx HTTP/1.1
> > User-Agent: Wget/1.14 (linux-gnu)
> > Accept: */*
> > Host: localhost:8000
> > Connection: Keep-Alive
> > Content-Type: application/x-www-form-urlencoded
> > Content-Length: 0
> >
> >
> > OT (I just see it): Why does Wget send 'Connection: Keep-Alive' here ?
> > It is not needed and causes unecessary impact on the server...
>
> Because Wget tries to reuse the same connection for multiple requests.
> For example, the server can respond with a redirection, which would
> require a new request, best carried out on the same connection.  (Plus,
> the code at that point doesn't have the information that it is the last
> request that will be run.)
>
>


-- 
Thanking You,
Darshit Shah
Research Lead, Code Innovation
Kill Code Phobia.
B.E.(Hons.) Mechanical Engineering, '14. BITS-Pilani


Re: [Bug-wget] Syntax for RESTful scripting options

2013-03-08 Thread Ángel González
On 08/03/13 19:18, Darshit Shah wrote:
> Okay gathering inputs from all the replies above., I think the best way to
> move forward would be to implement a --method=
> followed by --post-data or --post-file in case of POST and --put-data
> --put-file in case of the PUT option.
> In other cases wget expects the URL next.
> The GET option is included only for completeness.
>
> Please do let me know if I'm missing something.

Even easier, just accept anything as method, and send that (changing to
uppercase).

--post-data and --post-file would also work for put, but you may set --put-data
--put-file as aliases for niceness.



> Also, as Tim pointed out, wget does not test whether the file exists. I'll
> patch that too.
Good to fix that. But don't try to do everything in one big patch, send
one per feature.





Re: [Bug-wget] Syntax for RESTful scripting options

2013-03-08 Thread Tim Rühsen
Am Dienstag, 5. März 2013 schrieb Darshit Shah:
> Need some help with writing a test for this functionality.
> I have implemented a --method=HHTPMethod command that currently supports
> DELETE only.
> 
> I would be very grateful if someone can help me with writing a test to
> ensure that this is working correctly.
> Attaching the patch file that adds this functionality.

I am not shure, that a test for --method is needed.
Do you want to see Wget generate a DELETE request if you use --method=DELETE ? 
Just use -d ;-)

But to answer your request: You have to make HTTPServer.pm accept and answer 
DELETE requests (and POST would be nice then, too). Make a copy of a .px test 
and change the options of the wget command.

[just something personal]
I just did that for POST, but I can't see any benefit to add such a test.
And perl *really* sucks to me (but hey, i am a C and Java programmer).
It took me 45 minutes to understand the perl syntax + the existing test 
environment code... that is far too much for such a simple test environment. 
In fact, after that, the actual code change took me 3 minutes. 
But I know, I forget all about perl within hours or at least days... perl is 
"hack and forget" and a waste of time (to me, not to everyone).
I would prefer a C test environment for a C project, having tests written in 
C.

Regards, Tim



Re: [Bug-wget] Syntax for RESTful scripting options

2013-03-08 Thread Ángel González
On 07/03/13 05:37, Steven M. Schweda wrote:
>>> wget --options=POST `cat POSTdata` URL
>> Why not go with that?
>Apparently "always" means something to you which is different from
> what it means to me.
>
>It may be hard to believe, or you may not care, but some folks use
> this program on non-UNIX(-like) systems (VMS, for example), where such
> UNIX(-like) shell tricks are not available.  Even on UNIX(-like)
> systems, some old shells may have limited command-line length.  Some
> users might not want the contents of their file exposed to every user on
> the system who can run "ps".
>
>How many reasons do you need not to wreck existing functionality?
Or people may simply want to send a newline in the post data.


> So then how to unify --post-data and --post-file into one option? I too am
> not a bid advocate of changing the meaning according to the content but
> that seemed like the easiest way forward.
Don't do it.