cookie_jar.go 612 B

1234567891011121314151617181920212223242526272829
  1. package httpexpect
  2. import (
  3. "net/http"
  4. "net/http/cookiejar"
  5. "golang.org/x/net/publicsuffix"
  6. )
  7. // NewCookieJar returns a new http.CookieJar.
  8. //
  9. // Returned jar is implemented in net/http/cookiejar. PublicSuffixList is
  10. // implemented in golang.org/x/net/publicsuffix.
  11. //
  12. // Note that this jar ignores cookies when request url is empty.
  13. func NewCookieJar() http.CookieJar {
  14. jar, err := cookiejar.New(&cookiejar.Options{
  15. PublicSuffixList: publicsuffix.List,
  16. })
  17. if err != nil {
  18. panic(err)
  19. }
  20. return jar
  21. }
  22. // Deprecated: use NewCookieJar instead.
  23. func NewJar() http.CookieJar {
  24. return NewCookieJar()
  25. }