After some debugging I've found that the headers setter is calling the getter which calls a dynamic getter and ignores the new values
This declaration
open var headers : [String: String]? {
get { return socket.request.allHTTPHeaderFields }
set {
for (field, value) in headers ?? [:] {
socket.request.setValue(value, forHTTPHeaderField: field)
}
}
}
Should be replaced with this
open var headers : [String: String]? {
get { return socket.request.allHTTPHeaderFields }
set {
for (field, value) in newValue ?? [:] {
socket.request.setValue(value, forHTTPHeaderField: field)
}
}
}
If you need a test just run this example
let client: ActionCableClient = {
let _client = ActionCableClient(url: Defaults.Api.cableURL)
_client.headers = [
"Origin": "https://server.example"
]
return _client
}()
print(client.headers)
client.headers = [
"Origin": "https://server.example",
"Accept": "accept/json"
]
print(client.headers)
if !client.isConnected {
client.connect()
}
https://github.com/danielrhodes/Swift-ActionCableClient/blob/master/Source/Classes/ActionCableClient.swift#L77
After some debugging I've found that the
headerssetter is calling the getter which calls a dynamic getter and ignores the new valuesThis declaration
Should be replaced with this
If you need a test just run this example
https://github.com/danielrhodes/Swift-ActionCableClient/blob/master/Source/Classes/ActionCableClient.swift#L77