Skip to content

Commit

Permalink
Fail in Connection#write_frames if @framer is nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 20, 2024
1 parent 74b262e commit f80180b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/protocol/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ def write_frame(frame)
end

def write_frames
yield @framer
if @framer
yield @framer
else
raise EOFError, "Connection closed!"
end
end

def update_local_settings(changes)
Expand Down
9 changes: 9 additions & 0 deletions test/protocol/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
connection.read_frame
end.to raise_exception(Protocol::HPACK::Error)
end

it "can't write frames to a closed connection" do
connection.close

expect do
connection.write_frames do |framer|
end
end.to raise_exception(EOFError, message: be =~ /Connection closed/)
end
end

with 'client and server' do
Expand Down

0 comments on commit f80180b

Please sign in to comment.