func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) {
	if u.Scheme != "http" && u.Scheme != "https" {
		return cookies
	}
	host, err := canonicalHost(u.Host)
	if err != nil {
		return cookies
	}
	key := jarKey(host, j.psList)

	j.mu.Lock()
	defer j.mu.Unlock()

	submap := j.entries[key]
	if submap == nil {
		return cookies
	}

	https := u.Scheme == "https"
	path := u.Path
	if path == "" {
		path = "/"
	}

	modified := false
	var selected []entry
	for id, e := range submap {
		if e.Persistent && !e.Expires.After(now) {
			delete(submap, id)
			modified = true
			continue
		}
		if !e.shouldSend(https, host, path) {
			continue
		}
		e.LastAccess = now
		submap[id] = e
		selected = append(selected, e)
		modified = true
	}
	if modified {
		if len(submap) == 0 {
			delete(j.entries, key)
		} else {
			j.entries[key] = submap
		}
	}

	sort.Sort(byPathLength(selected))
	for _, e := range selected {
		cookies = append(cookies, &http.Cookie{Name: e.Name, Value: e.Value})
	}

	return cookies
}
// cookies is like Cookies but takes the current time as a parameter.
cookies is like Cookies but takes the current time as a parameter.
// cookies is like Cookies but takes the current time as a parameter .
func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) {
	if u.Scheme != "http" && u.Scheme != "https" {
		return cookies
	}
	host, err := canonicalHost(u.Host)
	if err != nil {
		return cookies
	}
	key := jarKey(host, j.psList)
	j.mu.Lock()
	defer j.mu.Unlock()
	submap := j.entries[key]
	if submap == nil {
		return cookies
	}
	https := u.Scheme == "https"
	path := u.Path
	if path == "" {
		path = "/"
	}
	modified := false
	var selected []entry
	for id, e := range submap {
		if e.Persistent && !e.Expires.After(now) {
			delete(submap, id)
			modified = true
			continue
		}
		if !e.shouldSend(https, host, path) {
			continue
		}
		e.LastAccess = now
		submap[id] = e
		selected = append(selected, e)
		modified = true
	}
	if modified {
		if len(submap) == 0 {
			delete(j.entries, key)
		} else {
			j.entries[key] = submap
		}
	}
	sort.Sort(byPathLength(selected))
	for _, e := range selected {
		cookies = append(cookies, &http.Cookie{Name: e.Name, Value: e.Value})
	}
	return cookies
}
func ( j * Jar ) cookies ( u * url . URL , now time . Time ) ( cookies [ ] * http . Cookie ) { if u . Scheme != " " && u . Scheme != " " { return cookies } host , err := canonicalHost ( u . Host ) if err != nil { return cookies } key := jarKey ( host , j . psList ) j . mu . Lock ( ) defer j . mu . Unlock ( ) submap := j . entries [ key ] if submap == nil { return cookies } https := u . Scheme == " " path := u . Path if path == " " { path = " " } modified := false var selected [ ] entry for id , e := range submap { if e . Persistent && ! e . Expires . After ( now ) { delete ( submap , id ) modified = true continue } if ! e . shouldSend ( https , host , path ) { continue } e . LastAccess = now submap [ id ] = e selected = append ( selected , e ) modified = true } if modified { if len ( submap ) == 0 { delete ( j . entries , key ) } else { j . entries [ key ] = submap } } sort . Sort ( byPathLength ( selected ) ) for _ , e := range selected { cookies = append ( cookies , & http . Cookie { Name : e . Name , Value : e . Value } ) } return cookies }
cookies is like Cookies but takes the current time as a parameter.
cookies is like Cookies but takes the current time as a parameter .