Re: Getting HEAD of the redirect message
Nigel Horne <[email protected]> Sun, 22 Aug 2010 14:21:55 +0100
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Organization | NJH Music |
| Message-ID | <[email protected]> |
On 22/08/10 14:04, Gisle Aas wrote: > On Mon, Aug 16, 2010 at 10:35, Nigel Horne<[email protected]> 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. I don't want to prevent the redirect from being followed, I want to see the contents of the redirect's header. > $ 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/ I'll give that a go. Thanks > --Gisle -Nigel