aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2018-07-04 12:45:35 +1200
committerGitHub <noreply@github.com>2018-07-04 12:45:35 +1200
commit93e185e1d41bc658328c69d637616ab355da513e (patch)
treef9dc7cdfc72952949f251dc640a5ff42a9768816 /actioncable/lib
parent90e2739d8680878b40224d68b366917b9c582ba5 (diff)
downloadrails-93e185e1d41bc658328c69d637616ab355da513e.tar.gz
rails-93e185e1d41bc658328c69d637616ab355da513e.tar.bz2
rails-93e185e1d41bc658328c69d637616ab355da513e.zip
Better compatibility with SPEC.
If `env` is duped or otherwise not the same as the original `env` that was generated at the top of rack middleware, it is impossible for the server hijack proc to update the right `env` instance. Therefore, capturing the return value is more reliable. This is the recommendation of the rack SPEC.
Diffstat (limited to 'actioncable/lib')
-rw-r--r--actioncable/lib/action_cable/connection/stream.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actioncable/lib/action_cable/connection/stream.rb b/actioncable/lib/action_cable/connection/stream.rb
index 4873026b71..e658948a55 100644
--- a/actioncable/lib/action_cable/connection/stream.rb
+++ b/actioncable/lib/action_cable/connection/stream.rb
@@ -98,8 +98,10 @@ module ActionCable
def hijack_rack_socket
return unless @socket_object.env["rack.hijack"]
- @socket_object.env["rack.hijack"].call
- @rack_hijack_io = @socket_object.env["rack.hijack_io"]
+ # This should return the underlying io according to the SPEC:
+ @rack_hijack_io = @socket_object.env["rack.hijack"].call
+ # Retain existing behaviour if required:
+ @rack_hijack_io ||= @socket_object.env["rack.hijack_io"]
@event_loop.attach(@rack_hijack_io, self)
end