On Mon, Aug 16, 2010 at 10:35, Nigel Horne <n...@bandsman.co.uk> wrote:
> How do I get the HEAD of the redirect message using the HEAD(1p) command?
>
> For example:
>
> HEAD http://www.ccdb.org.au/
>
> gives you the header of the site you've redirected to,
>
> HEAD -S http://www.ccdb.org.au/
>
> says:
>
> HEAD http://www.ccdb.org.au/ --> 302 Moved Temporarily
> HEAD http://www.ccdb.org.au/xzt25b9/ --> 200 OK
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0
> Connection: close
> ...
>
> Which doesn't help me, because the command hasn't actually printed the
> contents of the first header :-(

There is no way to prevent redirects from being followed with
lwp-request.  I'm usually happy just using lwp-dump for cases like
this.

$ lwp-dump http://www.ccdb.org.au/
HTTP/1.1 302 Found
Connection: Keep-Alive
Date: Sun, 22 Aug 2010 12:57:12 GMT
Location: http://www.ccdb.org.au/xzt25b9/
Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5
mod_bwlimited/1.4
Content-Length: 353
Content-Type: text/html; charset=iso-8859-1
Keep-Alive: timeout=5, max=100
[...]

If it's important that the method is 'HEAD' you can use something like:

perl -MLWP -le 'LWP::UserAgent->new(max_redirect=>0)->head(shift)->dump'
http://www.ccdb.org.au/

--Gisle

Reply via email to