Documentation ¶
Overview ¶
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar. It is a drop-in replacement for net/http/cookiejar which allows to inspect the content of the Jar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { Name string Value string Domain string Path string Secure bool HttpOnly bool Persistent bool HostOnly bool Expires time.Time Creation time.Time LastAccess time.Time // contains filtered or unexported fields }
Entry is the representation of a cookie in the jar. The exported fields are those of RFC 6265.
type Jar ¶
type Jar struct {
// contains filtered or unexported fields
}
Jar implements the http.CookieJar interface from the net/http package.
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) ETLDsPlus1 ¶
ETLDsPlus1 appends all effective top level domains + 1 or the IP address for which cookies are stored to dst and returns the extended slice.
func (*Jar) Entries ¶
Entries appends all jar entries stored for the given eTLD+1 to dst and returns the extended slice. The result set may be empty even if the eTLD+1 was reported by ETLDsPlus1, e.g. because cookies have expired.
func (*Jar) LoadEntries ¶
LoadEntries stores the values in entries in the jar j. Existing entries are updated. Invalied entries like expired entries or entries not acceptable due to the public suffix list in use are dropped silently. LoadEntries does not generate modification notifications on the Notify channel.
type Notification ¶
type Notification uint32
Notification is a bitmap of possible notification events generated by the Jar.
const ( ReadAccess Notification = 1 << iota // LastAccess modified in Cookies(). Expiration // Deleted because expiration detected in Cookies(). DeleteCookie // Deleted during SetCookies. SetCookie // Set or updated during SetCookies. )
Types of possible Notifications
type Options ¶
type Options struct { // PublicSuffixList is the public suffix list that determines whether // an HTTP server can set a cookie for a domain. // // A nil value is valid and may be useful for testing but it is not // secure: it means that the HTTP server for foo.co.uk can set a cookie // for bar.co.uk. PublicSuffixList cookiejar.PublicSuffixList // Notify is a channel on which the eTLDs+1 of all changed cookies // is annonced. // The caller must ensure that Notify has sufficient buffer space // to keep up with the expected change rate. Notify chan<- string // NotifyOn is the bitmap which determines which changes to the // jar will result in a notification message on the Notify channel. NotifyOn Notification }
Options are the options for creating a new Jar.