Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack hijack only works with Rack 3 specification. #10

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/protocol/rack/adapter/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ def unwrap_request(request, env)
env[CGI::HTTP_UPGRADE] = Array(protocol).join(",")
end

if request.respond_to?(:hijack?) and request.hijack?
env[RACK_HIJACK] = proc{request.hijack!.io.dup}
end

# HTTP/2 prefers `:authority` over `host`, so we do this for backwards compatibility.
env[CGI::HTTP_HOST] ||= request.authority

Expand Down
3 changes: 0 additions & 3 deletions lib/protocol/rack/adapter/rack2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class Rack2 < Generic
RACK_MULTIPROCESS = 'rack.multiprocess'
RACK_RUN_ONCE = 'rack.run_once'

RACK_IS_HIJACK = 'rack.hijack?'
RACK_HIJACK = 'rack.hijack'

def self.wrap(app)
Rewindable.new(self.new(app))
end
Expand Down
4 changes: 4 additions & 0 deletions lib/protocol/rack/adapter/rack3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def make_environment(request)

self.unwrap_request(request, env)

if request.respond_to?(:hijack?) and request.hijack?
env[RACK_HIJACK] = proc{request.hijack!.io.dup}
end

return env
end

Expand Down
4 changes: 4 additions & 0 deletions lib/protocol/rack/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ module CGI
RACK_URL_SCHEME = 'rack.url_scheme'
RACK_PROTOCOL = 'rack.protocol'
RACK_RESPONSE_FINISHED = 'rack.response_finished'

# Rack hijack support:
RACK_IS_HIJACK = 'rack.hijack?'
RACK_HIJACK = 'rack.hijack'
end
end
Loading