use go 1.1 cookiejar and revome ResetClient

This commit is contained in:
Victor Vieux 2013-06-17 18:13:40 +00:00
parent c7e63191fd
commit c7e86e5eab

View file

@ -7,10 +7,10 @@ import (
"fmt" "fmt"
"github.com/dotcloud/docker/auth" "github.com/dotcloud/docker/auth"
"github.com/dotcloud/docker/utils" "github.com/dotcloud/docker/utils"
"github.com/shin-/cookiejar"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/http/cookiejar"
"net/url" "net/url"
"strings" "strings"
) )
@ -438,11 +438,6 @@ func (r *Registry) SearchRepositories(term string) (*SearchResults, error) {
return result, err return result, err
} }
func (r *Registry) ResetClient(authConfig *auth.AuthConfig) {
r.authConfig = authConfig
r.client.Jar = cookiejar.NewCookieJar()
}
func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig { func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig {
password := "" password := ""
if withPasswd { if withPasswd {
@ -478,18 +473,18 @@ type Registry struct {
authConfig *auth.AuthConfig authConfig *auth.AuthConfig
} }
func NewRegistry(root string, authConfig *auth.AuthConfig) *Registry { func NewRegistry(root string, authConfig *auth.AuthConfig) (r *Registry, err error) {
httpTransport := &http.Transport{ httpTransport := &http.Transport{
DisableKeepAlives: true, DisableKeepAlives: true,
Proxy: http.ProxyFromEnvironment, Proxy: http.ProxyFromEnvironment,
} }
r := &Registry{ r = &Registry{
authConfig: authConfig, authConfig: authConfig,
client: &http.Client{ client: &http.Client{
Transport: httpTransport, Transport: httpTransport,
}, },
} }
r.client.Jar = cookiejar.NewCookieJar() r.client.Jar, err = cookiejar.New(nil)
return r return r, err
} }