Skip to content

Commit

Permalink
Any arrable object
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Katkov committed Sep 19, 2024
1 parent 30189db commit 449bdc8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/idempo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require "msgpack"
require "zlib"
require "set"
require "rack"
require 'rack'

require "idempo/version"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 449bdc8

Please sign in to comment.