in reply to missing content-length

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"; + }

Replies are listed 'Best First'.
Re: Re: missing content-length
by Anonymous Monk on Jan 22, 2001 at 21:12 UTC
    Thanks for the reply. Your code works fine with the free demo MP3 file you checked. But it doesn't work with MP3s that can only be accessed with an emusic.com account. But thanks to your code, I now know the reason:

    http://content.emusic.com/downloads/472279/Sean_Deason-Allegory_Metaphor-01-Creation.mp3

    gives me the following LWP error message:

    LWP::Protocol::http::request: HTTP/1.1 403 Forbidden
    LWP::UserAgent::request: Simple response: Forbidden

    So I guess my question is: how to get the size of a restricted file, where an HTTP request for a header does not work? Am I still in the right place to ask this question?