Proposal Details
Currently, since a jar's entries are not exposed to clear all cookies in a client's Jar in a thread-safe manner would require(from my understanding):
- Wrapping all calls to the client in a read lock, then write locking as the client's
Jar is replaced with a new empty jar.
- Keeping track of all URLs accessed in a thread-safe manner, getting the cookies for each of them, and overwriting each of those cookies with expired ones,
- Creating a Jar wrapping type storing a pointer to the jar that has an additional lock on each of the interface functions, and also a third Clear function that sets the pointer to the new jar. This is probably the most reasonable option.
Neither of those options are especially convenient, so I propose cookiejar adds a Clear() method that I will open a PR for. I am not proposing this is added to net/http's CookieJar as that would be a breaking change.
Proposal Details
Currently, since a jar's entries are not exposed to clear all cookies in a client's
Jarin a thread-safe manner would require(from my understanding):Jaris replaced with a new empty jar.Neither of those options are especially convenient, so I propose cookiejar adds a
Clear()method that I will open a PR for. I am not proposing this is added tonet/http'sCookieJaras that would be a breaking change.