Guest User

Untitled

a guest
Apr 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
  2. index 3d4133e..573c6ac 100644
  3. --- a/lib/rbot/core/utils/httputil.rb
  4. +++ b/lib/rbot/core/utils/httputil.rb
  5. @@ -126,14 +126,21 @@ module ::Net
  6. # the partial text at each chunk. Return the partial body.
  7. def partial_body(size=0, &block)
  8.  
  9. - self.no_cache = true
  10. partial = String.new
  11.  
  12. - self.read_body { |chunk|
  13. - partial << chunk
  14. + if @read
  15. + debug "using body() as partial"
  16. + partial = self.body
  17. yield self.body_to_utf(self.decompress_body(partial)) if block_given?
  18. - break if size and size > 0 and partial.length >= size
  19. - }
  20. + else
  21. + debug "disabling cache"
  22. + self.no_cache = true
  23. + self.read_body { |chunk|
  24. + partial << chunk
  25. + yield self.body_to_utf(self.decompress_body(partial)) if block_given?
  26. + break if size and size > 0 and partial.length >= size
  27. + }
  28. + end
  29.  
  30. return self.body_to_utf(self.decompress_body(partial))
  31. end
  32. @@ -629,7 +636,7 @@ class HttpUtil
  33. # _uri_:: uri to query (URI object or String)
  34. # _nbytes_:: number of bytes to get
  35. #
  36. - # Partia GET request, returns (if possible) the first _nbytes_ bytes of the
  37. + # Partial GET request, returns (if possible) the first _nbytes_ bytes of the
  38. # response body, following redirs and caching if requested, yielding the
  39. # actual response(s) to the optional block. See get_response for details on
  40. # the supported _options_
Add Comment
Please, Sign In to add comment