diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-10-29 20:48:36 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-10-29 20:48:36 +0000 |
commit | 34fa3a625fb63e927de8fd11769ced3c4d9cc83b (patch) | |
tree | 77dcdd9e181eadd4ffc21a4cff0835bfab29c75b /lib/rbot | |
parent | 0cf1ebaa5440085fb54358f0f36ab02bad0b269c (diff) |
httputil: support Content-Encoding: deflate
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/utils/httputil.rb | 12 |
1 files changed, 12 insertions, 0 deletions
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 |