Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(99)

Delta Between Two Patch Sets: src/pkg/http/proxy_test.go

Issue 4272045: code review 4272045: http: export Transport, add keep-alive support (Closed)
Left Patch Set: diff -r 604d3ae2f22e https://go.googlecode.com/hg/ Created 14 years ago
Right Patch Set: diff -r 61121e058bb8 https://go.googlecode.com/hg/ Created 13 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/http/persist.go ('k') | src/pkg/http/serve_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package http 5 package http
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 "testing" 9 "testing"
10 ) 10 )
11 11
12 // TODO(mattn): 12 // TODO(mattn):
13 // test ProxyAuth 13 // test ProxyAuth
14 14
15 var MatchNoProxyTests = []struct { 15 var UseProxyTests = []struct {
16 host string 16 host string
17 match bool 17 match bool
18 }{ 18 }{
19 » {"localhost", true}, // match completely 19 » {"localhost", false}, // match completely
20 » {"barbaz.net", true}, // match as .barbaz.net 20 » {"barbaz.net", false}, // match as .barbaz.net
21 » {"foobar.com:443", true}, // have a port but match· 21 » {"foobar.com:443", false}, // have a port but match·
22 » {"foofoobar.com", false}, // not match as a part of foobar.com 22 » {"foofoobar.com", true}, // not match as a part of foobar.com
23 » {"baz.com", false}, // not match as a part of barbaz.com 23 » {"baz.com", true}, // not match as a part of barbaz.com
24 » {"localhost.net", false}, // not match as suffix of address 24 » {"localhost.net", true}, // not match as suffix of address
25 » {"local.localhost", false}, // not match as prefix as address 25 » {"local.localhost", true}, // not match as prefix as address
26 » {"barbarbaz.net", false}, // not match because NO_PROXY have a '.' 26 » {"barbarbaz.net", true}, // not match because NO_PROXY have a '.'
27 » {"www.foobar.com", false}, // not match because NO_PROXY is not .foobar .com 27 » {"www.foobar.com", true}, // not match because NO_PROXY is not .foobar. com
28 } 28 }
29 29
30 func TestMatchNoProxy(t *testing.T) { 30 func TestUseProxy(t *testing.T) {
31 oldenv := os.Getenv("NO_PROXY") 31 oldenv := os.Getenv("NO_PROXY")
32 no_proxy := "foobar.com, .barbaz.net , localhost" 32 no_proxy := "foobar.com, .barbaz.net , localhost"
33 os.Setenv("NO_PROXY", no_proxy) 33 os.Setenv("NO_PROXY", no_proxy)
34 defer os.Setenv("NO_PROXY", oldenv) 34 defer os.Setenv("NO_PROXY", oldenv)
35 35
36 tr := &Transport{} 36 tr := &Transport{}
37 37
38 » for _, test := range MatchNoProxyTests { 38 » for _, test := range UseProxyTests {
39 » » if tr.matchNoProxy(test.host) != test.match { 39 » » if tr.useProxy(test.host) != test.match {
40 if test.match { 40 if test.match {
41 » » » » t.Errorf("matchNoProxy(%v) = %v, want %v", test. host, !test.match, test.match) 41 » » » » t.Errorf("useProxy(%v) = %v, want %v", test.host , !test.match, test.match)
42 } else { 42 } else {
43 t.Errorf("not expected: '%s' shouldn't match as '%s'", test.host, no_proxy) 43 t.Errorf("not expected: '%s' shouldn't match as '%s'", test.host, no_proxy)
44 } 44 }
45 } 45 }
46 } 46 }
47 } 47 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b