Skip to content

Commit

Permalink
Fix implementation of rack.hijack. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Dec 11, 2023
1 parent 3a9ff0e commit 2023f79
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
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

0 comments on commit 2023f79

Please sign in to comment.