Re: Subclass of both WWW::Mechanize::GZip and WWW::Mechanize::Sleepy
[email protected] (Peng Yu) Wed, 17 Aug 2011 17:32:05 -0500
| Newsgroups | perl.libwww |
|---|---|
| Message-ID | <CABrM6wm2ztXpbR902p5QOjpBDQD5UUVPkUoLwJjQAYHUqTAojg@mail.gmail.com> |
On Wed, Aug 17, 2011 at 5:19 PM, Andy Lester <[email protected]> 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); -- Regards, Peng