diff --git a/Sources/KituraWebSocket/PermessageDeflate.swift b/Sources/KituraWebSocket/PermessageDeflate.swift index c3fb64b..4d2043e 100644 --- a/Sources/KituraWebSocket/PermessageDeflate.swift +++ b/Sources/KituraWebSocket/PermessageDeflate.swift @@ -26,8 +26,9 @@ class PermessageDeflate: WebSocketProtocolExtension { guard header.hasPrefix("permessage-deflate") else { return [] } var deflaterMaxWindowBits: Int32 = 15 var inflaterMaxWindowBits: Int32 = 15 - var clientNoContextTakeover = false - let serverNoContextTakeover = false //TODO: `let` for now, needs to be a `var` when we start handling this parameter + //TODO: change these defaults to false after implementing context takeover + var clientNoContextTakeover = true + var serverNoContextTakeover = true // Four parameters to handle: // * server_max_window_bits: the LZ77 sliding window size used by the server for compression @@ -57,10 +58,13 @@ class PermessageDeflate: WebSocketProtocolExtension { } } - //TODO: If server_no_context_takeover was received, do we create new inflater/deflater objects? - if parameter == "client_no_context_takeover" { + if parameter.hasPrefix("client_no_context_takeover") { clientNoContextTakeover = true } + + if parameter.hasPrefix("server_no_context_takeover") { + serverNoContextTakeover = true + } } return [PermessageDeflateCompressor(maxWindowBits: deflaterMaxWindowBits, noContextTakeOver: serverNoContextTakeover), @@ -77,9 +81,16 @@ class PermessageDeflate: WebSocketProtocolExtension { for parameter in header.components(separatedBy: "; ") { if parameter == "client_no_context_takeover" { - response.append("; \(parameter)") + //TODO: include client_no_context_takeover in the response + } + + if parameter == "server_no_context_takeover" { + //TODO: include server_no_context_takeover in the response } } + //TODO: remove this after we have implemented context takeover + response.append("; server_no_context_takeover") + response.append("; client_no_context_takeover") return response } }