It's hard to answer as I can't reproduce (ok, ok it's also beccause I'm just an initiate... ;-)
It just works fine for me: I got the content-length
Does it always fail ? or just on one file ? or (apparently) randomly ?
Is there a possibility that you mis-type the filename or
something like that ?
(Don't feel offended!)
Anyway I've slightly modified your code (to check other things
(LWP debug code+ the full header to see what was returned...)
What's the result when you execute this:
(replace the filename)
require LWP::UserAgent;
use LWP::Debug('+');
$ua = new LWP::UserAgent;
$request = new HTTP::Request('HEAD',
'http://content.emusic.com/demo/542259/Guitar_Slim-Sufferin_Mind-01-Th
+e_Things_That_I_Used_To_Do-demo.mp3');
$response = $ua->request($request);
my %headers=%{$response->headers};
print "dooh" if !defined($response->headers->content_length);
for my $value (keys %headers) { print "($value)=($headers{$value})\n";
+ }
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.