A platform for community discussion. Free, open, simple.
FIX: ensure proper header transfer (except for cache control)
Samfc36f095a736
diff --git a/lib/hijack.rb b/lib/hijack.rbindex a8a1268fb1d..51a4659591e 100644--- a/lib/hijack.rb+++ b/lib/hijack.rb@@ -23,6 +23,8 @@ module Hijackio = hijack.call+ original_headers = response.headers+Scheduler::Defer.later("hijack #{params["controller"]} #{params["action"]}") doMethodProfiler.start(transfer_timings)@@ -39,6 +41,12 @@ module Hijackinstance.response = responseinstance.request = request_copy+ original_headers&.each do |k, v|+ # hash special handling so skip+ if k != "Cache-Control"+ instance.response.headers[k] = v+ end+ endbegininstance.instance_eval(&blk)@@ -68,13 +76,13 @@ module Hijackstatus_string = Rack::Utils::HTTP_STATUS_CODES[response.status.to_i] || "Unknown"io.write "#{response.status} #{status_string}\r\n"- headers.each do |name, val|- io.write "#{name}: #{val}\r\n"- end-timings = MethodProfiler.stopif timings && duration = timings[:total_duration]- io.write "X-Runtime: #{"%0.6f" % duration}\r\n"+ headers["X-Runtime"] = "#{"%0.6f" % duration}"+ end++ headers.each do |name, val|+ io.write "#{name}: #{val}\r\n"endio.write "\r\n"diff --git a/spec/components/hijack_spec.rb b/spec/components/hijack_spec.rbindex a9f92ef309b..7d3c0c3ad85 100644--- a/spec/components/hijack_spec.rb+++ b/spec/components/hijack_spec.rb@@ -114,6 +114,16 @@ describe Hijack doexpect(headers).to eq(expected)end+ it "handles transfers headers" do+ tester.response.headers["Hello-World"] = "sam"+ tester.hijack_test do+ expires_in 1.year+ render body: "hello world", status: 402+ end++ expect(tester.io.string).to include("Hello-World: sam")+ end+it "handles expires_in" dotester.hijack_test doexpires_in 1.year