[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] wget post needs better docs
From: |
Micah Cowan |
Subject: |
Re: [Bug-wget] wget post needs better docs |
Date: |
Wed, 18 Feb 2009 08:24:35 -0800 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
Fernando Cassia wrote:
> Hi,
>
> This is a RFE as I think the docs or the --help could perhaps be
> improved. See below.
>
> I´ve done simple username and password style http-post requests before
> with wget, but now I´m trying to do something a bit more complex:
>
> #1 Retrieve an URL (txt), keep session cookies, and then
> #2 Post that txt file as one of the http post variables, along with
> two other variables (username and password).
>
> Well, it´s not clear by looking at the docs how to accomplish that. I
> mean, if I use
>
> --post-data 'user=foo&password=bar' that sends the two vars, but how
> do I make it send the contents of file.txt as var content as part of
> the same request?
>
> wget --help reads:
>
> --post-data=STRING use the POST method; send STRING as the data.
> --post-file=FILE use the POST method; send contents of FILE.
>
> Well, I want to send --post-data="user=foo&password=bar"
> --post-file="contents=" content.txt {url}
These two functions are not intended to be used together. If they are
both specified, --post-file will be ignored.
Note that --post-file is not for "attaching files" to a form post: it
does exactly the same thing as --post-data, and takes exactly the same
sort of 'foo=bar&baz=quux' values. The _only_ difference between the two
is that --post-data takes its values from the commandline, while the
other reads it from a file. This is mentioned in the docs, but IMO not
very clearly; I'll file a bug against them.
Currently Wget does not do multipart form posts, which would be
necessary for posting files properly. Currently to post files, you have
to specify them as a regular name/value pair, and take care to
percent-encode the file contents (yuck!). Note that there is then no way
to specify the file's encoding.
Multipart form posting is a planned feature for a future release of Wget.
--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
GNU Maintainer: wget, screen, teseq
http://micah.cowan.name/