Re: wget request methods GET vs. POST vs. PUT vs. etc.

From: Troy Melhase <troy@gci.net>
Date: Sun Mar 28 2004 - 20:53:30 AKST

On Sunday 28 March 2004 07:59 pm, DENNIS BYRNE wrote:
> wget http://url -postvars searchterm "alaska" display "cities"

from the wget man page on my system:

      --post-data=string
       --post-file=file
           Use POST as the method for all HTTP requests and send the specified
           data in the request body. "--post-data" sends string as data,
           whereas "--post-file" sends the contents of file. Other than that,
           they work in exactly the same way.

           Please be aware that Wget needs to know the size of the POST data
           in advance. Therefore the argument to "--post-file" must be a reg-
           ular file; specifying a FIFO or something like /dev/stdin won't
           work. It's not quite clear how to work around this limitation
           inherent in HTTP/1.0. Although HTTP/1.1 introduces chunked trans-
           fer that doesn't require knowing the request length in advance, a
           client can't use chunked unless it knows it's talking to an
           HTTP/1.1 server. And it can't know that until it receives a
           response, which in turn requires the request to have been completed
           -- a chicken-and-egg problem.

           Note: if Wget is redirected after the POST request is completed, it
           will not send the POST data to the redirected URL. This is because
           URLs that process POST often respond with a redirection to a regu-
           lar page (although that's technically disallowed), which does not
           desire or accept POST. It is not yet clear that this behavior is
           optimal; if it doesn't work out, it will be changed.

           This example shows how to log to a server using POST and then pro-
           ceed to download the desired pages, presumably only accessible to
           authorized users:

                   # Log in to the server. This can be done only once.
                   wget --save-cookies cookies.txt \
                        --post-data 'user=foo&password=bar' \
                        http://server.com/auth.php

                   # Now grab the page or pages we care about.
                   wget --load-cookies cookies.txt \
                        -p http://server.com/interesting/article.php

-- 
Troy Melhase, troy@gci.net
--
I am the Christian the Devil warned you about.
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sun Mar 28 20:48:53 2004

This archive was generated by hypermail 2.1.8 : Sun Mar 28 2004 - 20:48:53 AKST