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

Add public initializer to HTTPCookieStorage #5148

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

agisboye
Copy link
Contributor

The Foundation docs state that HTTPCookieStorage can be subclassed. This, however, is impossible to do with the swift-corelibs-foundation version since there are no publicly accessible initializers.

subclass
class MyCookieStorage: HTTPCookieStorage {
    init(someParameter: String) {
        super.init() // Accessible on Darwin but not on other platforms
    }
}

This PR adds an initializer. It has no parameters similar to the Darwin version.
From what I can gather, when a HTTPCookieStorage is initialized, it's completely separate from the shared storage and only lives as long as there is a reference to it (i.e. cookies are not persisted).

@parkera parkera requested a review from guoye-zhang December 17, 2024 21:53
@guoye-zhang
Copy link

Looks OK to me. -init is inherited from NSObject on Darwin I believe.

@zhenchaoli Does HTTPCookieStorage() also create an in-memory cookie storage on Darwin?

@zhenchaoli
Copy link

Seems that on Darwin HTTPCookieStorage() does not have internal backing store, so setting/retrieving cookies are no-ops.

@agisboye
Copy link
Contributor Author

@guoye-zhang, @zhenchaoli I've changed the behavior such that setting cookies is a no-op (making all the other operations no-ops as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants