Don't send a close frame in response to receiving one, if we already sent a close frame.

This commit is contained in:
James Coglan
2015-03-14 10:03:26 +00:00
parent 47fe3a7479
commit b78ed7706d
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -246,7 +246,7 @@ module WebSocket
end
def shutdown(code, reason)
frame(reason, :close, code)
frame(reason, :close, code) if @ready_state < 2
@frame = @message = nil
@ready_state = 3
@stage = 5
+5
View File
@@ -457,6 +457,11 @@ describe WebSocket::Driver::Hybi do
it "changes the state to :closed" do
expect(driver.state).to eq :closed
end
it "does not write another close frame" do
expect(socket).not_to receive(:write)
driver.parse [0x88, 0x04, 0x03, 0xe9, 0x4f, 0x4b].pack("C*")
end
end
end