summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-01 15:04:53 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-01 15:04:53 +0000
commit84e53ad77fae1fd7e924986c5f36a04115e13ffc (patch)
treef7665a5cb712bf3c3a70938fef7fd8c1f07afae5 /lib/rbot
parente47d9daf3beb3b6ab34c5c7a5b84f3019241b035 (diff)
httputil: reinstate partial_body
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/httputil.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
index 4ce8dcc3..78445abe 100644
--- a/lib/rbot/core/utils/httputil.rb
+++ b/lib/rbot/core/utils/httputil.rb
@@ -20,6 +20,25 @@ rescue LoadError => e
error "Secured HTTP connections will fail"
end
+module ::Net
+ class HTTPResponse
+ # Read chunks from the body until we have at least _size_ bytes, yielding
+ # the partial text at each chunk. Return the partial body.
+ def partial_body(size=0, &block)
+
+ partial = String.new
+
+ self.read_body { |chunk|
+ partial << chunk
+ yield partial if block_given?
+ break if size and size > 0 and partial.length >= size
+ }
+
+ return partial
+ end
+ end
+end
+
Net::HTTP.version_1_2
module ::Irc