On 1/8/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
On Mon, Jan 08, 2007 at 03:57:20PM +0100, Gisle Aas wrote:

> This method will also undo various Content-Encodings for you.
> look at the source for decoded_content you will notice that it parse
> the Content-Type header using:
>
>        if (my @ct =
> HTTP::Headers::Util::split_header_words($self->header("Content-Type")))
> {
>            ($ct, undef, %ct_param) = @{$ct[-1]};
>            $ct = lc($ct);
>        }

It would be handy to have a charset method.

Noted.

A few questions.

Since $res->decoded_content decodes encodings, is there any code to
help set Accept-Encoding based on what you use for uncompressing the
content?

No.  One possible way would be to just create test HTTP::Response
object with an empty gzip body and then try to decode it.

use LWP::UserAgent;
require HTTP::Response;

my $ua = LWP::UserAgent->new;
$ua->default_headers->push_header(Accept_Encoding => "gzip, x-gzip")
    if defined(HTTP::Response->new(200, "OK",
        [Content_Encoding => "gzip"],
        pack("H*","1f8b08089194a2450003780003000000000000000000"),
    )->decoded_content);


I was doing the uncompressing manually, and setting my
Accept-Encoding by first seeing what modules could be loaded.

Think it's safe for my code to test for Compress::Zlib and then add
"gzip, x-gzip, deflate" as Accept-Encoding?

I think so to.

--Gisle

Reply via email to