> 
> 
> -----Original Message-----
> From: Peng Yu [mailto:pengyu...@gmail.com] 
> Sent: 17 August 2011 23:32
> To: Andy Lester
> Cc: libwww@perl.org
> Subject: Re: Subclass of both WWW::Mechanize::GZip and
WWW::Mechanize::Sleepy
> 
> On Wed, Aug 17, 2011 at 5:19 PM, Andy Lester <a...@petdance.com> wrote:
> >
> > On Aug 17, 2011, at 5:05 PM, Peng Yu wrote:
> >
> > Hi,
> >
> > I'd like to use the features of both WWW::Mechanize::GZip and 
> > WWW::Mechanize::Sleepy. Does anybody let me know what I should use? Is 
> > there a subclass of both?
> >
> > If ::GZip just ungzips content as it comes in, that's now a built-in 
> > feature of Mech.  And I know that the fucntionality of ::Sleepy is 
> > pretty trivial, and could be incorporated into your own subclass of 
> > Mech with minimal effort.
> > xoa
> 
> According to man WWW::Mechanize, there is an internal method.
> 
>    $mech->_modify_request( $req )
>        Modifies a HTTP::Request before the request is sent out, for both
GET and POST requests.
> 
>        We add a "Referer" header, as well as header to note that we can
accept gzip encoded content, if Compress::Zlib is installed.
> 
> 
> I have Compress::Zlib installed. But it seems that I have to explicit
called it to modify the request. But I don't want to do so as it is an
internal method.
> 
> Currently, I do the following. But this wastes some bandwidth. Would you
please let me know how to use WWW::Mechanize with gzip?
> 
> $browser->add_header('Accept-Encoding' => 'identity'); my $response =
$browser->get($uri);

Looking at the WWW::Mechanize code, it looks like it already handles gzip.

If you want an origin server to return gzipped content you can't get around
having to add this header to the HTTP request 

        Accept-Encoding: gzip

This is what WWW::Mechanize will do if it detects Compress::Zlib is
available.

Note - by using the "identity" content-encoding you are requesting that the
origin server does not return gzipped content. I assume that isn't what you
want to happen.

If WWW::Mechanize handles gzip content for you, does that mean that
WWW::Mechanize::Sleepy meets your requirements

Paul

Reply via email to