Skip to content

Commit

Permalink
Merge 9224cee into 9b4a4ce
Browse files Browse the repository at this point in the history
  • Loading branch information
HoneyryderChuck committed Aug 28, 2018
2 parents 9b4a4ce + 9224cee commit 868c9e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/http/2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def initialize(**settings)
@error = nil

@h2c_upgrade = nil
@closed_since = nil
end

def closed?
Expand Down Expand Up @@ -144,6 +145,7 @@ def goaway(error = :no_error, payload = nil)
send(type: :goaway, last_stream: last_stream,
error: error, payload: payload)
@state = :closed
@closed_since = Time.now
end

# Sends a WINDOW_UPDATE frame to the peer.
Expand Down Expand Up @@ -446,12 +448,15 @@ def connection_management(frame)
# the connection, although a new connection can be established
# for new streams.
@state = :closed
@closed_since = Time.now
emit(:goaway, frame[:last_stream], frame[:error], frame[:payload])
when :altsvc, :blocked
emit(frame[:type], frame)
else
connection_error
end
when :closed
connection_error if (Time.now - @closed_since) > 15
else
connection_error
end
Expand Down
9 changes: 9 additions & 0 deletions spec/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,15 @@
expect { @conn.new_stream }.to raise_error(ConnectionClosed)
end

it 'should not raise error when receiving connection management frames immediately after emitting goaway' do
@conn.goaway
expect(@conn).to be_closed

expect { @conn << f.generate(SETTINGS.dup) }.not_to raise_error(ProtocolError)
expect { @conn << f.generate(PING.dup) }.not_to raise_error(ProtocolError)
expect { @conn << f.generate(GOAWAY.dup) }.not_to raise_error(ProtocolError)
end

it 'should process connection management frames after GOAWAY' do
@conn << f.generate(SETTINGS.dup)
@conn << f.generate(HEADERS.dup)
Expand Down

0 comments on commit 868c9e5

Please sign in to comment.