rack 3.1.16 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/rack/events.rb CHANGED
@@ -29,12 +29,13 @@ module Rack
29
29
  #
30
30
  # * on_send(request, response)
31
31
  #
32
- # The webserver has started iterating over the response body and presumably
33
- # has started sending data over the wire. This method is always called with
34
- # a request object and the response object. The response object is
35
- # constructed from the rack triple that the application returned. Changes
36
- # SHOULD NOT be made to the response object as the webserver has already
37
- # started sending data. Any mutations will likely result in an exception.
32
+ # The webserver has started iterating over the response body, or has called
33
+ # the streaming body, and presumably has started sending data over the
34
+ # wire. This method is always called with a request object and the response
35
+ # object. The response object is constructed from the rack triple that the
36
+ # application returned. Changes SHOULD NOT be made to the response object
37
+ # as the webserver has already started sending data. Any mutations will
38
+ # likely result in an exception.
38
39
  #
39
40
  # * on_finish(request, response)
40
41
  #
@@ -90,6 +91,20 @@ module Rack
90
91
  @handlers.reverse_each { |handler| handler.on_send request, response }
91
92
  super
92
93
  end
94
+
95
+ def call(stream)
96
+ @handlers.reverse_each { |handler| handler.on_send request, response }
97
+ super
98
+ end
99
+
100
+ def respond_to?(method_name, include_all = false)
101
+ case method_name
102
+ when :each, :call
103
+ @body.respond_to?(method_name, include_all)
104
+ else
105
+ super
106
+ end
107
+ end
93
108
  end
94
109
 
95
110
  class BufferedResponse < Rack::Response::Raw # :nodoc:
data/lib/rack/head.rb CHANGED
@@ -15,9 +15,8 @@ module Rack
15
15
  _, _, body = response = @app.call(env)
16
16
 
17
17
  if env[REQUEST_METHOD] == HEAD
18
- response[2] = Rack::BodyProxy.new([]) do
19
- body.close if body.respond_to? :close
20
- end
18
+ body.close if body.respond_to?(:close)
19
+ response[2] = []
21
20
  end
22
21
 
23
22
  response