logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: libwww-perl-5.802: msg#00035

Subject: Re: libwww-perl-5.802
Moshe Kaminsky <kaminsky@xxxxxxxxxxxxxxx> writes:

> * Gisle Aas <gisle@xxxxxxxxxxxxxxx> [01/12/04 12:02]:
> > libwww-perl-5.802 is available from CPAN. The changes since 5.801 are:
> > 
> >     The HTTP::Message object now have a decoded_content() method.
> >     This will return the content after any Content-Encodings and
> >     charsets has been decoded.
> > 
> 
> For some reason, the original content is killed in the response object 
> when I use this method - the content() method returns an empty string 
> after calling decoded_content. The reason appears to be passing 
> $$content_ref to Encode::decode in line 220 of HTTP/Message.pm. I guess 
> it's probably some problem with decode(),
> but in any case, replacing that line with
> 
> my $cont = $$content_ref;
> $content_ref = \Encode::decode($charset, $cont, Encode::FB_CROAK());
> 
> Solved the problem. This is with HTTP::Message version 1.52, perl 
> version 5.8.6, Encode version 2.08 on linux.

Thanks for your report.  There was a similar issue with memGunzip and
the patch I applied for it will also fix this problem.

> Also, I would like to suggest adding a flag, which will cause the 
> content() method to return the output of decoded_content(). This will 
> allow scripts which ignored the charset to automatically do the right 
> thing by simply setting this flag.

I'm not too happy about this suggestion asis.  One option is to
introduce a '$mess->decode_content' method and then make
LWP::UserAgent grow some option that makes it automatically call this
for all responses it receives.  The 'decode_content' would be like

    $resp->content(encode_utf8($res->decoded_content));

but would also fix up the Content-Encoding and Content-Type header.

Regards,
Gisle




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>