1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
16 var cacheKeysTests
= []struct {
22 {"", "http", "foo.com", "|http|foo.com"},
23 {"", "https", "foo.com", "|https|foo.com"},
24 {"http://foo.com", "http", "foo.com", "http://foo.com|http|"},
25 {"http://foo.com", "https", "foo.com", "http://foo.com|https|foo.com"},
28 func TestCacheKeys(t
*testing
.T
) {
29 for _
, tt
:= range cacheKeysTests
{
32 u
, err
:= url
.Parse(tt
.proxy
)
38 cm
:= connectMethod
{proxyURL
: proxy
, targetScheme
: tt
.scheme
, targetAddr
: tt
.addr
}
39 if got
:= cm
.key().String(); got
!= tt
.key
{
40 t
.Fatalf("{%q, %q, %q} cache key = %q; want %q", tt
.proxy
, tt
.scheme
, tt
.addr
, got
, tt
.key
)
45 func ResetProxyEnv() {
46 for _
, v
:= range []string{"HTTP_PROXY", "http_proxy", "NO_PROXY", "no_proxy", "REQUEST_METHOD"} {
49 ResetCachedEnvironment()