Avoid delivering websocket frames twice on EOF. (#368)

Motivation:

Unfortunately as a result of #108 the WebSocketFrameDecoder can emit a
WebSocketFrame more than once if the user closes the connection in
channelRead, or any other callback while decode() is on the call stack.
This is obviously less than ideal, as it can allow multiple delivery of
frames.

Modifications:

Given WebSocketFrameDecoder a no-op implementation of decodeLast.

Result:

No multi-delivery of frames.
This commit is contained in:
Cory Benfield authored and GitHub committed 2018-04-27 11:02:51 +01:00
1 parent ec47847b4b
commit 708a62d257
3 files changed
+51

No files matched your search

@@ -269,6 +269,11 @@ public final class WebSocketFrameDecoder: ByteToMessageDecoder {
return .needMoreData
}
public func decodeLast(ctx: ChannelHandlerContext, buffer: inout ByteBuffer) throws -> DecodingState {
// EOF is not semantic in WebSocket, so ignore this.
return .needMoreData
}
/// Apply a number of validations to the incremental state, ensuring that the frame we're
/// receiving is valid.
private func validateState() throws {