]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/utils/httputil.rb
filters: suppress a warning
[user/henk/code/ruby/rbot.git] / lib / rbot / core / utils / httputil.rb
index 2c83cebb4f80a017bdae007a8cb6edb11bf174b5..573c6aca91b30949c45c015e8889231739f065da 100644 (file)
@@ -126,14 +126,21 @@ module ::Net
     # the partial text at each chunk. Return the partial body.
     def partial_body(size=0, &block)
 
-      self.no_cache = true
       partial = String.new
 
-      self.read_body { |chunk|
-        partial << chunk
+      if @read
+        debug "using body() as partial"
+        partial = self.body
         yield self.body_to_utf(self.decompress_body(partial)) if block_given?
-        break if size and size > 0 and partial.length >= size
-      }
+      else
+        debug "disabling cache"
+        self.no_cache = true
+        self.read_body { |chunk|
+          partial << chunk
+          yield self.body_to_utf(self.decompress_body(partial)) if block_given?
+          break if size and size > 0 and partial.length >= size
+        }
+      end
 
       return self.body_to_utf(self.decompress_body(partial))
     end
@@ -283,7 +290,7 @@ class HttpUtil
       'Accept-Charset' => 'utf-8;q=1.0, *;q=0.8',
       'Accept-Encoding' => 'gzip;q=1, deflate;q=1, identity;q=0.8, *;q=0.2',
       'User-Agent' =>
-        "rbot http util #{$version} (http://linuxbrit.co.uk/rbot/)"
+        "rbot http util #{$version} (#{Irc::Bot::SOURCE_URL})"
     }
     debug "starting http cache cleanup timer"
     @timer = @bot.timer.add(300) {
@@ -629,7 +636,7 @@ class HttpUtil
   # _uri_::     uri to query (URI object or String)
   # _nbytes_::  number of bytes to get
   #
-  # Partia GET request, returns (if possible) the first _nbytes_ bytes of the
+  # Partial GET request, returns (if possible) the first _nbytes_ bytes of the
   # response body, following redirs and caching if requested, yielding the
   # actual response(s) to the optional block. See get_response for details on
   # the supported _options_