Re: I get an error in message->content_charset

Gisle Aas <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On Mon, Sep 21, 2009 at 09:34, Jesper Jørgen Persson
<[email protected]> wrote:
> require LWP::UserAgent;
> require HTTP::Request;
> $request = HTTP::Request->new(GET => 'http://www.utm.edu/departments/finearts/calen.htm');
> $ua = LWP::UserAgent->new();
> $response = $ua->request($request);
> $content_charset = $response->content_charset();
> ^D
> Can't use an undefined value as an ARRAY reference at C:/Perl/site/lib/HTTP/Message.pm line 251.
> Summary of my perl5 (revision 5 version 8 subversion 9)libwww version: 5.831

LWP ends up confused about the meta elements with empty content on
that page.  The following fix will appear in 5.832:

--- a/lib/HTTP/Message.pm
+++ b/lib/HTTP/Message.pm
@@ -248,6 +248,7 @@ sub content_charset
                    if (my $c = $attr->{content}) {
                        require HTTP::Headers::Util;
                        my @v = HTTP::Headers::Util::split_header_words($c);
+                       return unless @v;
                        my($ct, undef, %ct_param) = @{$v[0]};
                        $charset = $ct_param{charset};
                    }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.