1use strict;
2use warnings;
3use Test::More;
4use t::Util;
5
6my $server = spawn_h2o(<< "EOT");
7http2-idle-timeout: 5
8hosts:
9  default:
10    paths:
11      /:
12        file.dir: @{[ DOC_ROOT ]}
13EOT
14
15
16my $output = run_with_h2get($server, <<"EOR");
17    to_process = []
18    h2g = H2.new
19    authority = ARGV[0] || "localhost:8080"
20    host = "https://#{authority}"
21    h2g.connect(host)
22    h2g.send_prefix()
23    h2g.send_settings([[SETTINGS_INITIAL_WINDOW_SIZE,0]])
24    i = 0
25    while i < 2 do
26        f = h2g.read(-1)
27        if f.type == "SETTINGS" and (f.flags == ACK) then
28            i += 1
29        elsif f.type == "SETTINGS" then
30            h2g.send_settings_ack()
31            i += 1
32        end
33    end
34
35    req = {
36        ":method" => "GET",
37        ":authority" => host,
38        ":scheme" => "https",
39        ":path" => "/",
40    }
41    h2g.send_headers(req, 1, END_HEADERS | END_STREAM)
42    open_streams = {}
43    open_streams[1] = 1
44    while open_streams.length > 0
45        f = h2g.read(20000)
46        if f == nil
47          puts "timeout"
48          exit 1
49        else
50          puts "#{f.type}, stream_id:#{f.stream_id}, len:#{f.len}, flags:#{f.flags}"
51        end
52        if f.type == "GOAWAY" then
53          exit
54        end
55
56        if f.type == "DATA" or f.type == "HEADERS" then
57            if f.is_end_stream
58                open_streams.delete(f.stream_id)
59            end
60        end
61    end
62    puts("ok")
63EOR
64like $output, qr{\nGOAWAY}, "Received a GOAWAY frame";
65unlike $output, qr{timeout}, "Script didn't time out";
66
67done_testing();
68