Documentation ¶
Overview ¶
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
This implementation is a fork of net/http/cookiejar which also implements methods for dumping the cookies to persistent storage and retrieving them.
Index ¶
- func DefaultCookieFile() string
- type Jar
- func (j *Jar) AllCookies() (cookies []*http.Cookie)
- func (j *Jar) Cookies(u *url.URL) (cookies []*http.Cookie)
- func (j *Jar) MarshalJSON() ([]byte, error)
- func (j *Jar) RemoveAll()
- func (j *Jar) RemoveAllHost(host string)
- func (j *Jar) RemoveCookie(c *http.Cookie)
- func (j *Jar) Save() error
- func (j *Jar) SetCookies(u *url.URL, cookies []*http.Cookie)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCookieFile ¶
func DefaultCookieFile() string
DefaultCookieFile returns the default cookie file to use for persisting cookie data. The following names will be used in decending order of preference:
- the value of the $GOCOOKIES environment variable.
- $HOME/.go-cookies
Types ¶
type Jar ¶
type Jar struct {
// contains filtered or unexported fields
}
Jar implements the http.CookieJar interface from the net/http package.
func New ¶
New returns a new cookie jar. A nil *Options is equivalent to a zero Options.
New will return an error if the cookies could not be loaded from the file for any reason than if the file does not exist.
func (*Jar) AllCookies ¶
AllCookies returns all cookies in the jar. The returned cookies will have Domain, Expires, HttpOnly, Name, Secure, Path, and Value filled out. Expired cookies will not be returned. This function does not modify the cookie jar.
func (*Jar) Cookies ¶
Cookies implements the Cookies method of the http.CookieJar interface.
It returns an empty slice if the URL's scheme is not HTTP or HTTPS.
func (*Jar) MarshalJSON ¶
MarshalJSON implements json.Marshaler by encoding all persistent cookies currently in the jar.
func (*Jar) RemoveAllHost ¶
RemoveAllHost removes any cookies from the jar that were set for the given host.
func (*Jar) RemoveCookie ¶
RemoveCookie removes the cookie matching the name, domain and path specified by c.
type Options ¶
type Options struct { // PublicSuffixList is the public suffix list that determines whether // an HTTP server can set a cookie for a domain. // // If this is nil, the public suffix list implementation in golang.org/x/net/publicsuffix // is used. PublicSuffixList cookiejar.PublicSuffixList // Filename holds the file to use for storage of the cookies. // If it is empty, the value of DefaultCookieFile will be used. Filename string // NoPersist specifies whether no persistence should be used // (useful for tests). If this is true, the value of Filename will be // ignored. NoPersist bool }
Options are the options for creating a new Jar.
Directories ¶
Path | Synopsis |
---|---|
Package lock is a file locking library.
|
Package lock is a file locking library. |
Package retry implements flexible retry loops, including support for channel cancellation, mocked time, and composable retry strategies including exponential backoff with jitter.
|
Package retry implements flexible retry loops, including support for channel cancellation, mocked time, and composable retry strategies including exponential backoff with jitter. |