From f996958e4e34ad768e6fa35e3d39ca546defd768 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 23 Apr 2021 14:17:44 +1200 Subject: [PATCH] Raise an exception when a full hijack has occurred. Returning a nil response is invalid. Fixes #106. --- lib/falcon/adapters/rack.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/falcon/adapters/rack.rb b/lib/falcon/adapters/rack.rb index 70e6752f..3d97868b 100644 --- a/lib/falcon/adapters/rack.rb +++ b/lib/falcon/adapters/rack.rb @@ -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" @@ -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