Skip to content

Commit f80180b

Browse files
committed
Fail in Connection#write_frames if @framer is nil.
1 parent 74b262e commit f80180b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/protocol/http2/connection.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ def write_frame(frame)
211211
end
212212

213213
def write_frames
214-
yield @framer
214+
if @framer
215+
yield @framer
216+
else
217+
raise EOFError, "Connection closed!"
218+
end
215219
end
216220

217221
def update_local_settings(changes)

test/protocol/http2/connection.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@
6565
connection.read_frame
6666
end.to raise_exception(Protocol::HPACK::Error)
6767
end
68+
69+
it "can't write frames to a closed connection" do
70+
connection.close
71+
72+
expect do
73+
connection.write_frames do |framer|
74+
end
75+
end.to raise_exception(EOFError, message: be =~ /Connection closed/)
76+
end
6877
end
6978

7079
with 'client and server' do

0 commit comments

Comments
 (0)