lib/eat.rb in eat-0.1.6 vs lib/eat.rb in eat-0.1.7
- old
+ new
@@ -7,13 +7,15 @@
unless defined?(::Infinity)
::Infinity = 1.0/0
end
module Eat
+ # httpclient 2.2.3 inserts the platform info for you, albeit with problems
+ # AGENT_NAME = "Mozilla/5.0 (#{::RUBY_PLATFORM}) Ruby/#{::RUBY_VERSION} HTTPClient/#{::HTTPClient::VERSION} eat/#{::Eat::VERSION}"
+ AGENT_NAME = "eat/#{::Eat::VERSION}"
+
module ObjectExtensions
- AGENT_NAME = "Mozilla/5.0 (#{::RUBY_PLATFORM}) Ruby/#{::RUBY_VERSION} HTTPClient/#{::HTTPClient::VERSION} eat/#{::Eat::VERSION}"
-
# <tt>url</tt> can be filesystem or http/https
#
# Options:
# * <tt>:timeout</tt> in seconds
# * <tt>:limit</tt> is characters (bytes in Ruby 1.8)
@@ -55,14 +57,18 @@
http.transparent_gzip_decompression = true
http.receive_timeout = timeout
if uri.scheme == 'https'
http.ssl_config.verify_mode = openssl_verify_mode
end
- catch :stop do
- http.get_content(uri.to_s) do |chunk|
- body << chunk
- read_so_far += chunk.length
- throw :stop if read_so_far > limit
+ if limit == ::Infinity
+ body << http.get_content(uri.to_s)
+ else
+ catch :stop do
+ http.get_content(uri.to_s) do |chunk|
+ body << chunk
+ read_so_far += chunk.length
+ throw :stop if read_so_far > limit
+ end
end
end
end
limit == ::Infinity ? body.join : body.join[0...limit]