-
Notifications
You must be signed in to change notification settings - Fork 12
/
cont-repro.rb
64 lines (61 loc) · 1.62 KB
/
cont-repro.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
begin
to_process = []
h2g = H2.new
host = ARGV[0] || "www.google.com"
puts "#######################"
puts "# #{host}"
puts "#######################"
h2g.connect(host)
h2g.send_prefix()
h2g.send_settings()
open_streams = {}
# Ack settings
while true do
f = h2g.read(-1)
puts f.to_s
if f.type == "SETTINGS" and (f.flags & 1 == 1) then
next
elsif f.type == "SETTINGS" then
h2g.send_settings_ack()
break
else
to_process << f
end
end
to_process.each do |f|
puts f.to_s
end
req = {
":method" => "GET",
":authority" => host,
":scheme" => "https",
":path" => "/",
}
h2g.send_headers(req, 15, 0)
h2g.send_continuation({"x-test" => "1"}, 15, END_STREAM | END_HEADERS)
open_streams[15] = 1
while open_streams.length > 0
f = h2g.read(-1)
puts "type:#{f.type}, stream_id:#{f.stream_id}, len:#{f.len}, flags:#{f.flags}"
if f.type == "GOAWAY" then
puts f.to_s
elsif f.type == "PING" then
f.ack()
elsif f.type == "SETTINGS" then
puts f.to_s
elsif f.type == "DATA" and f.len > 0 then
h2g.send_window_update(0, f.len)
h2g.send_window_update(f.stream_id, f.len)
elsif f.type == "HEADERS" then
puts f.to_s
end
if f.type == "DATA" or f.type == "HEADERS" then
if f.is_end_stream
open_streams.delete(f.stream_id)
end
end
end
rescue => e
p e
exit 1
end