1
0
mirror of https://github.com/golang/go synced 2024-10-07 05:21:22 -06:00
go/src/pkg/net/http/jar.go
Volker Dobler dd694fb149 net/http: Added interface for a cookie jar.
Types implementing CookieJar may be used in a Client
to persist cookies.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5399043
2011-12-16 10:48:41 -05:00

31 lines
1003 B
Go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http
import (
"net/url"
)
// A CookieJar manages storage and use of cookies in HTTP requests.
//
// Implementations of CookieJar must be safe for concurrent use by multiple
// goroutines.
type CookieJar interface {
// SetCookies handles the receipt of the cookies in a reply for the
// given URL. It may or may not choose to save the cookies, depending
// on the jar's policy and implementation.
SetCookies(u *url.URL, cookies []*Cookie)
// Cookies returns the cookies to send in a request for the given URL.
// It is up to the implementation to honor the standard cookie use
// restrictions such as in RFC 6265.
Cookies(u *url.URL) []*Cookie
}
type blackHoleJar struct{}
func (blackHoleJar) SetCookies(u *url.URL, cookies []*Cookie) {}
func (blackHoleJar) Cookies(u *url.URL) []*Cookie { return nil }