Starscream
Starscream copied to clipboard
Bug fix with cookie on iOS 12
Hi,
We have found that HTTPCookieStorage.shared.cookies(for: url) in HTTPHandler.createUpgrade returns nil in case of wss scheme for iOS 12 (works fine for iOS 13+). So we think that
if let cookies = HTTPCookieStorage.shared.cookies(for: httpUrl ?? url), !cookies.isEmpty {
let headers = HTTPCookie.requestHeaderFields(with: cookies)
for (key, val) in headers {
req.setValue(val, forHTTPHeaderField: key)
}
}
should be changed to:
let scheme = (url.scheme == "ws" ? "http" : (url.scheme == "wss" ? "https" : url.scheme)) ?? ""
let httpUrl = URL(string: scheme + "://" + (url.host ?? "") + url.path)
if let cookies = HTTPCookieStorage.shared.cookies(for: httpUrl ?? url), !cookies.isEmpty {
let headers = HTTPCookie.requestHeaderFields(with: cookies)
for (key, val) in headers {
req.setValue(val, forHTTPHeaderField: key)
}
}
It looks like a workaround, but seems to work for all versions.
Any updates for this issue?
Is there any reply?