[committed] Fix newlib build failure with rx as well as several dozen testsuite failures
[official-gcc.git] / libgo / go / net / http / proxy_test.go
blob0dd57b41253ee6e59b8ece7d44b56722a2387236
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.
5 package http
7 import (
8 "net/url"
9 "os"
10 "testing"
13 // TODO(mattn):
14 // test ProxyAuth
16 var cacheKeysTests = []struct {
17 proxy string
18 scheme string
19 addr string
20 key string
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 {
30 var proxy *url.URL
31 if tt.proxy != "" {
32 u, err := url.Parse(tt.proxy)
33 if err != nil {
34 t.Fatal(err)
36 proxy = u
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"} {
47 os.Unsetenv(v)
49 ResetCachedEnvironment()