diff options
author | Eric Wong <BOFH@YHBT.net> | 2023-06-05 10:12:33 +0000 |
---|---|---|
committer | Eric Wong <bofh@yhbt.net> | 2023-06-05 10:38:38 +0000 |
commit | fbdf627a138ffcaa589a7bb29559a3c6f9297a24 (patch) | |
tree | 6f220871d61a1bc6c1caa0431faf3026c366ece3 /t | |
parent | 7544ccba6d6b9f388b7a88a0a54a8a95616f0eae (diff) | |
download | unicorn-fbdf627a138ffcaa589a7bb29559a3c6f9297a24.tar.gz |
One more socat dependency down...
Diffstat (limited to 't')
-rw-r--r-- | t/integration.ru | 16 | ||||
-rw-r--r-- | t/integration.t | 11 | ||||
-rwxr-xr-x | t/t0000-http-basic.sh | 50 |
3 files changed, 27 insertions, 50 deletions
diff --git a/t/integration.ru b/t/integration.ru index 12f5d48..c0bef99 100644 --- a/t/integration.ru +++ b/t/integration.ru @@ -32,6 +32,21 @@ def write_on_close [ 200, { 'transfer-encoding' => 'chunked' }, WriteOnClose.new ] end +def env_dump(env) + require 'json' + h = {} + env.each do |k,v| + case v + when String, Integer, true, false; h[k] = v + else + case k + when 'rack.version', 'rack.after_reply'; h[k] = v + end + end + end + h.to_json +end + run(lambda do |env| case env['REQUEST_METHOD'] when 'GET' @@ -40,6 +55,7 @@ run(lambda do |env| 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', {}, [] ] + when '/env_dump'; [ 200, {}, [ env_dump(env) ] ] when '/write_on_close'; write_on_close end # case PATH_INFO (GET) when 'POST' diff --git a/t/integration.t b/t/integration.t index 3ab5c90..ee22e7e 100644 --- a/t/integration.t +++ b/t/integration.t @@ -47,6 +47,17 @@ is_deeply([ grep(/^x-r3: /, @$hdr) ], [ 'x-r3: a', 'x-r3: b', 'x-r3: c' ], 'rack 3 array headers supported') or diag(explain($hdr)); +SKIP: { + eval { require JSON::PP } or skip "JSON::PP missing: $@", 1; + $c = tcp_connect($srv); + print $c "GET /env_dump\r\n" or die $!; + my $json = do { local $/; readline($c) }; + unlike($json, qr/^Connection: /smi, 'no connection header for 0.9'); + unlike($json, qr!\AHTTP/!s, 'no HTTP/1.x prefix for 0.9'); + my $env = JSON::PP->new->decode($json); + is(ref($env), 'HASH', 'JSON decoded body to hashref'); + is($env->{SERVER_PROTOCOL}, 'HTTP/0.9', 'SERVER_PROTOCOL is 0.9'); +} # cf. <CAO47=rJa=zRcLn_Xm4v2cHPr6c0UswaFC_omYFEH+baSxHOWKQ@mail.gmail.com> $c = tcp_connect($srv); diff --git a/t/t0000-http-basic.sh b/t/t0000-http-basic.sh deleted file mode 100755 index 8ab58ac..0000000 --- a/t/t0000-http-basic.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -. ./test-lib.sh -t_plan 8 "simple HTTP connection tests" - -t_begin "setup and start" && { - unicorn_setup - unicorn -D -c $unicorn_config env.ru - unicorn_wait_start -} - -t_begin "single request" && { - curl -sSfv http://$listen/ -} - -t_begin "check stderr has no errors" && { - check_stderr -} - -t_begin "HTTP/0.9 request should not return headers" && { - ( - printf 'GET /\r\n' - cat $fifo > $tmp & - wait - echo ok > $ok - ) | socat - TCP:$listen > $fifo -} - -t_begin "env.inspect should've put everything on one line" && { - test 1 -eq $(count_lines < $tmp) -} - -t_begin "no headers in output" && { - if grep ^Connection: $tmp - then - die "Connection header found in $tmp" - elif grep ^HTTP/ $tmp - then - die "HTTP/ found in $tmp" - fi -} - -t_begin "killing succeeds" && { - kill $unicorn_pid -} - -t_begin "check stderr has no errors" && { - check_stderr -} - -t_done |