From: "Luis G." Date: 2011-02-28T20:08:30+09:00 Subject: mechanize and Content Encoding Error Hello guys. I'm trying to get some files from a webpage using Mechanize. Something like this: begin Timeout::timeout(25){ res = agent.get(torrent_download).save_as(filename) } rescue SocketError => e log.error 'Fail saving the file '+filename+': SocketError' end rescue SystemCallError => e log.error 'Fail saving the file '+filename+': SystemCallError' end rescue Timeout::Error => e log.error 'Fail saving the file '+filename+' Timeout::Error' end rescue Net::HTTPBadResponse => e log.error 'Fail saving the file '+filename+' HTTPBadResponse' end rescue Mechanize::ResponseCodeError => e log.error 'Fail saving the file '+filename+' Mechanize::RespError' end end Everything was working perfectly till I found a page that, if we access using browser, we get the following error: Content Encoding Error (http://support.mozilla.com/en-US/kb/error%20loading%20web%20sites#w_content-encoding-error) When I get a page like that I get the following exception: /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/body_decoding_handler.rb:24:in `inflate': invalid stored block lengths (Zlib::DataError) from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/body_decoding_handler.rb:24:in `handle' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain.rb:29:in `pass' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/handler.rb:6:in `handle' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/response_reader.rb:35:in `handle' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain.rb:24:in `handle' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:543:in `fetch_page' from /usr/lib/ruby/1.8/net/http.rb:1053:in `request' from /usr/lib/ruby/1.8/net/http.rb:2140:in `reading_body' from /usr/lib/ruby/1.8/net/http.rb:1052:in `request' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:538:in `fetch_page' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:611:in `fetch_page' from /var/lib/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:259:in `get' ... How can I handle this exception? SystemCallError shouldn't handle all kind of exceptions, including this one? Any ideas? Thanks, Luis -- Posted via http://www.ruby-forum.com/.