Browse files

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.
  • Loading branch information...
ioquatix committed Jul 4, 2018
1 parent 90e2739 commit 93e185e1d41bc658328c69d637616ab355da513e
Showing with 4 additions and 2 deletions.
  1. +4 −2 actioncable/lib/action_cable/connection/stream.rb
@@ -98,8 +98,10 @@ def receive(data)
def hijack_rack_socket
return unless @socket_object.env["rack.hijack"]
@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)

0 comments on commit 93e185e

Please sign in to comment.