Skip to content

Commit

Permalink
Raise an exception when a full hijack has occurred.
Browse files Browse the repository at this point in the history
Returning a nil response is invalid. Fixes #105.
  • Loading branch information
ioquatix committed Apr 23, 2021
1 parent 45ca2be commit fffce85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/falcon/adapters/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Rack
RACK_IS_HIJACK = 'rack.hijack?'
RACK_HIJACK_IO = 'rack.hijack_io'

# Raised back up through the middleware when the underlying connection is hijacked.
class FullHijack < StandardError
end

# Async::HTTP specific metadata:

ASYNC_HTTP_REQUEST = "async.http.request"
Expand Down Expand Up @@ -202,7 +206,7 @@ def call(request)

# If there was a full hijack:
if full_hijack
return nil
raise FullHijack, "The connection was hijacked."
else
return Response.wrap(status, headers, body, request)
end
Expand Down

0 comments on commit fffce85

Please sign in to comment.