Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom URLSessionConfiguration.httpCookieStorage is ignored #234

Open
guillermomuntaner opened this issue Apr 21, 2022 · 0 comments
Open
Labels

Comments

@guillermomuntaner
Copy link

guillermomuntaner commented Apr 21, 2022

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

  1. Use a custom httpCookieStorage. In our case, we use a HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: "groupname") to share cookies between app and extensions
  2. Plug netfox, do any request
  3. 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:

  1. (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.
  2. (Probably good enought) Provide a way to configure the URLSession that NFXProtocol uses so we can configure it too
@guillermomuntaner guillermomuntaner changed the title Custom URLSessionConfiguration.httpCookieStorage are ignored Custom URLSessionConfiguration.httpCookieStorage is ignored Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant