Describe the bug
Custom URLSessionConfiguration.httpCookieStorage are not honored:
public extension Session {
static let customSession: Session = {
let sessionConfiguraton = URLSessionConfiguration.default
sessionConfiguraton.protocolClasses?.insert(NFXProtocol.self, at: 0)
sessionConfiguraton.httpCookieStorage = customCookieStorage
return Session(configuration: sessionConfiguraton)
}()
}
To Reproduce
Use a custom httpCookieStorage. In our case, we use a HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: "groupname") to share cookies between app and extensions
Plug netfox, do any request
Cookies are not added from / saved to the expected httpCookieStorage
Expected behavior
Cookies are get/set into the configured httpCookieStorage. Instead they seem to be saved into the default one.
Additional context
My guess is that cookie handling happens in the URLProtocol implementation that the NFXProtocol shadows. Internally the NFXProtocol uses a URLSession(configuration: .default, ...) session which doesn't use the httpCookieStorage we want it to use.
I guess the solution is either or:
(Ideally) Fix the NFXProtocol to use the httpCookieStorage. Unfortunately I am not familiar with URLProtocol so I don't know exactly what is missing here.
(Probably good enought) Provide a way to configure the URLSession that NFXProtocol uses so we can configure it too
Describe the bug Custom
URLSessionConfiguration.httpCookieStorage
are not honored:To Reproduce
HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: "groupname")
to share cookies between app and extensionsExpected behavior Cookies are get/set into the configured
httpCookieStorage
. Instead they seem to be saved into the default one.Additional context My guess is that cookie handling happens in the
URLProtocol
implementation that theNFXProtocol
shadows. Internally theNFXProtocol
uses aURLSession(configuration: .default, ...)
session which doesn't use thehttpCookieStorage
we want it to use.I guess the solution is either or:
NFXProtocol
to use thehttpCookieStorage
. Unfortunately I am not familiar withURLProtocol
so I don't know exactly what is missing here.URLSession
thatNFXProtocol
uses so we can configure it too