Skip to content

proposal: net/http/cookiejar: add Jar.Clear #70258

@AidanWelch

Description

@AidanWelch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions