diff --git a/lib/idempo.rb b/lib/idempo.rb index fac3a43..f5c2b68 100644 --- a/lib/idempo.rb +++ b/lib/idempo.rb @@ -7,7 +7,7 @@ require "msgpack" require "zlib" require "set" -require "rack" +require 'rack' require "idempo/version" @@ -56,7 +56,7 @@ def call(env) end status, headers, body = @app.call(env) - if Gem::Version.new(Rack.release) >= Gem::Version.new("3.0") + if Gem::Version.new(Rack.release) >= Gem::Version.new('3.0') # `body` could be of type `ActionDispatch::Response::RackBody` and idempo will not even attempt to store it, # we're converting ActionDispatch::Response::RackBody to a storable array format. body = body.try(:to_ary) if body.respond_to?(:to_ary) @@ -123,7 +123,7 @@ def response_may_be_persisted?(status, headers, body) def body_size_within_limit?(response_headers, body) return response_headers["Content-Length"].to_i <= SAVED_RESPONSE_BODY_SIZE_LIMIT if response_headers["Content-Length"] - return false unless body.is_a?(Array) # Arbitrary iterable of unknown size + return false unless body.is_a?(Array) || body.respond_to?(:to_ary) # Arbitrary iterable of unknown size sum_of_string_bytesizes(body) <= SAVED_RESPONSE_BODY_SIZE_LIMIT end