Skip to content

Commit

Permalink
temporary workaround: always default to no context takeover (#24)
Browse files Browse the repository at this point in the history
temporary workaround: always refuse context takeover
  • Loading branch information
Pushkar N Kulkarni authored May 17, 2019
1 parent 1655b2a commit 026e018
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Sources/KituraWebSocket/PermessageDeflate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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
}
}

0 comments on commit 026e018

Please sign in to comment.