diff options
author | Akira Matsuda <ronnie@dio.jp> | 2022-07-09 16:46:19 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-09 19:46:19 +1200 |
commit | 7a9401dadf27dedee36d1920727b0384facbb37b (patch) | |
tree | 38443df2995c079dab8a1d126aaba444b7859375 /lib/rack/deflater.rb | |
parent | 1206f3bc2346511b04a70c9dc6925218e1a4b4e8 (diff) | |
download | rack-7a9401dadf27dedee36d1920727b0384facbb37b.tar.gz |
Reuse the Array object from parent middleware (#1887)
in order not to allocate another Array object for passing the response to the next middleware. Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
Diffstat (limited to 'lib/rack/deflater.rb')
-rw-r--r-- | lib/rack/deflater.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb index 8e18e160..3f6177e6 100644 --- a/lib/rack/deflater.rb +++ b/lib/rack/deflater.rb @@ -44,10 +44,10 @@ module Rack end def call(env) - status, headers, body = @app.call(env) + status, headers, body = response = @app.call(env) unless should_deflate?(env, status, headers, body) - return [status, headers, body] + return response end request = Request.new(env) @@ -67,9 +67,10 @@ module Rack headers.delete(CONTENT_LENGTH) mtime = headers["last-modified"] mtime = Time.httpdate(mtime).to_i if mtime - [status, headers, GzipStream.new(body, mtime, @sync)] + response[2] = GzipStream.new(body, mtime, @sync) + response when "identity" - [status, headers, body] + response else # when nil # Only possible encoding values here are 'gzip', 'identity', and nil message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found." |