From 34fa3a625fb63e927de8fd11769ced3c4d9cc83b Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 29 Oct 2007 20:48:36 +0000 Subject: httputil: support Content-Encoding: deflate --- lib/rbot/core/utils/httputil.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb index d9b88839..dc3b6b99 100644 --- a/lib/rbot/core/utils/httputil.rb +++ b/lib/rbot/core/utils/httputil.rb @@ -101,6 +101,18 @@ module ::Net end return ret end + when 'deflate' + debug "inflating body" + # From http://www.koders.com/ruby/fid927B4382397E5115AC0ABE21181AB5C1CBDD5C17.aspx?s=thread: + # -MAX_WBITS stops zlib from looking for a zlib header + inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS) + begin + return inflater.inflate(str) + rescue Zlib::Error => e + raise e + # TODO + # debug "full inflation failed (#{e}), trying to recover as much as possible" + end else raise "Unhandled content encoding #{method}" end -- cgit v1.2.3