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.
This commit is contained in:
Samuel Williams 2018-07-04 12:45:35 +12:00 committed by GitHub
parent 90e2739d86
commit 93e185e1d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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