From ea0559c700fa029044464de4bd572662c10b7273 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 5 Jun 2023 10:12:31 +0000 Subject: [PATCH 02/23] support rack 3 multi-value headers The first step in adding Rack 3 support. Rack supports multi-value headers via array rather than newlines. Tested-by: Martin Posthumus Link: https://yhbt.net/unicorn-public/7c851d8a-bc57-7df8-3240-2f5ab831c47c@gmail.com/ --- t/integration.ru | 1 + t/integration.t | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/t/integration.ru b/t/integration.ru index 6ef873c..5183217 100644 --- a/t/integration.ru +++ b/t/integration.ru @@ -23,6 +23,7 @@ def restore_status_code when 'GET' case env['PATH_INFO'] when '/rack-2-newline-headers'; [ 200, { 'X-R2' => "a\nb\nc" }, [] ] + when '/rack-3-array-headers'; [ 200, { 'x-r3' => %w(a b c) }, [] ] when '/nil-header-value'; [ 200, { 'X-Nil' => nil }, [] ] when '/unknown-status-pass-through'; [ '666 I AM THE BEAST', {}, [] ] end # case PATH_INFO (GET) diff --git a/t/integration.t b/t/integration.t index 5569155..e876c71 100644 --- a/t/integration.t +++ b/t/integration.t @@ -38,6 +38,15 @@ SKIP: { # Date header check diag(explain([$t, $!, \@d])); }; + +$c = tcp_connect($srv); +print $c "GET /rack-3-array-headers HTTP/1.0\r\n\r\n" or die $!; +($status, $hdr) = slurp_hdr($c); +is_deeply([ grep(/^x-r3: /, @$hdr) ], + [ 'x-r3: a', 'x-r3: b', 'x-r3: c' ], + 'rack 3 array headers supported') or diag(explain($hdr)); + + # cf. $c = tcp_connect($srv); print $c "GET /nil-header-value HTTP/1.0\r\n\r\n" or die $!;