mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
websockets: connection closed frame must be flushed
Motivation: Because EmbeddedChannel used to treat all writes as flushed the test that tested that we do send out the WebSockets connection close frame didn't actually test the right thing. Now that EmbeddedChannel behaves more realisticly, this test actually fails. This fixes the bug and the test that tests that a WebSockets connection is successfully torn down after an error occured. Modifications: - use `writeAndFlush` to send out the connection close frame. Result: WebSockets connection actually gets closed on error.
This commit is contained in:
1 parent
c3d02b8d47
commit
5aa140ca96
1 file changed
+2
-2
@@ -312,8 +312,8 @@ public final class WebSocketFrameDecoder: ByteToMessageDecoder {
|
||||
let frame = WebSocketFrame(fin: true,
|
||||
opcode: .connectionClose,
|
||||
data: data)
|
||||
_ = ctx.write(self.wrapOutboundOut(frame)).then {
|
||||
ctx.close()
|
||||
ctx.writeAndFlush(self.wrapOutboundOut(frame)).whenComplete {
|
||||
ctx.close(promise: nil)
|
||||
}
|
||||
ctx.fireErrorCaught(error)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user