From 6e943a4deeedd39443014fad0d450ae13f913ba0 Mon Sep 17 00:00:00 2001 From: Ismael Celis Date: Sat, 22 Nov 2025 17:26:18 +0000 Subject: [PATCH] Remove Connection response header in Async (Fibers) mode The Falcon Ruby server (currently the option for Fiber-based concurrency) ignores "hop headers" such as Connection, and displays a warning in HTTP mode (it just removes them in HTTPS) https://github.com/socketry/falcon/blob/8292c26f6972b88149bc1dc5f9abb1f9c66ca039/lib/falcon/middleware/proxy.rb#L35 When using the AsyncExecutor (ie running under Falcon), remove the Connection header from the Response. --- lib/datastar/async_executor.rb | 4 +++- spec/async_executor_spec.rb | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 spec/async_executor_spec.rb diff --git a/lib/datastar/async_executor.rb b/lib/datastar/async_executor.rb index 9faab15..c140c31 100644 --- a/lib/datastar/async_executor.rb +++ b/lib/datastar/async_executor.rb @@ -22,7 +22,9 @@ def initialize def new_queue = Async::Queue.new - def prepare(response); end + def prepare(response) + response.delete_header 'Connection' + end def spawn(&block) Async(&block) diff --git a/spec/async_executor_spec.rb b/spec/async_executor_spec.rb new file mode 100644 index 0000000..9eef0ad --- /dev/null +++ b/spec/async_executor_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +RSpec.describe Datastar::AsyncExecutor do + it 'removes Connection header from response' do + executor = described_class.new + response = Rack::Response.new(nil, 200, { 'Connection' => 'keep-alive'}) + executor.prepare(response) + expect(response.headers.key?('Connection')).to be(false) + end +end