func (c config) jar() (*cookiejar.Jar, error) {
	opts := c.DriverOptions
	jar, err := cookiejar.New(&cookiejar.Options{
		PublicSuffixList: publicsuffix.List,
	})
	if err != nil {
		return nil, err
	}

	if opts == nil || opts.UseCDP {
		return jar, nil
	}

	for i, ckURL := range opts.Cookies {
		url, err := url.Parse(ckURL.CookieURL) // CookieURL must be valid, include schema
		if err != nil {
			logger.Warnf("skipping cookie [%d] for cookieURL %s: %v", i, ckURL.CookieURL, err)
			continue
		}

		var httpCookies []*http.Cookie
		for _, cookie := range ckURL.Cookies {
			c := &http.Cookie{
				Name:   cookie.Name,
				Value:  getCookieValue(cookie),
				Path:   cookie.Path,
				Domain: cookie.Domain,
			}
			httpCookies = append(httpCookies, c)
		}

		jar.SetCookies(url, httpCookies)
		if jar.Cookies(url) == nil {
			logger.Warnf("setting jar cookies for %s failed", url.String())
		}
	}

	return jar, nil
}
// jar constructs a cookie jar from a configuration
jar constructs a cookie jar from a configuration
// jar constructs a cookie jar from a configuration
func (c config) jar() (*cookiejar.Jar, error) {
	opts := c.DriverOptions
	jar, err := cookiejar.New(&cookiejar.Options{
		PublicSuffixList: publicsuffix.List,
	})
	if err != nil {
		return nil, err
	}
	if opts == nil || opts.UseCDP {
		return jar, nil
	}
	for i, ckURL := range opts.Cookies {
		url, err := url.Parse(ckURL.CookieURL) 
		if err != nil {
			logger.Warnf("skipping cookie [%d] for cookieURL %s: %v", i, ckURL.CookieURL, err)
			continue
		}
		var httpCookies []*http.Cookie
		for _, cookie := range ckURL.Cookies {
			c := &http.Cookie{
				Name:   cookie.Name,
				Value:  getCookieValue(cookie),
				Path:   cookie.Path,
				Domain: cookie.Domain,
			}
			httpCookies = append(httpCookies, c)
		}
		jar.SetCookies(url, httpCookies)
		if jar.Cookies(url) == nil {
			logger.Warnf("setting jar cookies for %s failed", url.String())
		}
	}
	return jar, nil
}
func ( c config ) jar ( ) ( * cookiejar . Jar , error ) { opts := c . DriverOptions jar , err := cookiejar . New ( & cookiejar . Options { PublicSuffixList : publicsuffix . List , } ) if err != nil { return nil , err } if opts == nil || opts . UseCDP { return jar , nil } for i , ckURL := range opts . Cookies { url , err := url . Parse ( ckURL . CookieURL ) if err != nil { logger . Warnf ( " " , i , ckURL . CookieURL , err ) continue } var httpCookies [ ] * http . Cookie for _ , cookie := range ckURL . Cookies { c := & http . Cookie { Name : cookie . Name , Value : getCookieValue ( cookie ) , Path : cookie . Path , Domain : cookie . Domain , } httpCookies = append ( httpCookies , c ) } jar . SetCookies ( url , httpCookies ) if jar . Cookies ( url ) == nil { logger . Warnf ( " " , url . String ( ) ) } } return jar , nil }
jar constructs a cookie jar from a configuration
jar constructs a cookie jar from a configuration
// CookieURL must be valid, include schema