bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget GET vs HEAD


From: Darshit Shah
Subject: Re: wget GET vs HEAD
Date: Mon, 3 Feb 2020 16:31:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1



On 03/02/2020 16:08, Peng Yu wrote:
Hi,

I'd like to understand the following two commands. One uses GET, the
other uses HEAD.

wget -q -O /dev/null -S -o- URL
wget -q --spider -S -o- URL

Is there first still download response body? Does wget know that its
/dev/null so that it just download the header and ignore the response
body?

No. Wget does not perform this optimization. As mentioned by Tim, there are many valid usecases where one would want to actually download the body, but not store it.


If I only want the reponse header, and GET and HEAD result in the same
header for my purpose, I should use the 2nd one to save time as it
does not have response body?


Yes. In an ideal world, GET and HEAD should always return exactly the same headers (See RFC2616, sec. 9.4). However, some servers do not follow this (*cough* Google *cough*). If it works fine for you, yes, you can simply use the `--spider` option to get only the headers.

If that doesn't work, there is another possible hack, __if__ the server supports HTTP/1.1 Range Headers. You can explicitly send `--header=Range: bytes=0-1`. This will cause the server to send only 1 byte of the body. If you pass `--unlink` or `-O/dev/null` then the file will be automatically deleted for you as well
Thanks.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]