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

Side by Side Diff: src/net/http/client_test.go

Issue 152570049: [dev.power64] code review 152570049: all: merge default into dev.power64 (Closed)
Patch Set: diff -r 36f7fc9495481ed67a159eea0eb2fac35b7c46a5 https://code.google.com/p/go Created 10 years, 4 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:
View unified diff | Download patch
« no previous file with comments | « src/net/http/client.go ('k') | src/net/http/cookie.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Tests for client.go 5 // Tests for client.go
6 6
7 package http_test 7 package http_test
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } 1029 }
1030 want := Header{ 1030 want := Header{
1031 "Server-Trailer-A": []string{"valuea"}, 1031 "Server-Trailer-A": []string{"valuea"},
1032 "Server-Trailer-B": nil, 1032 "Server-Trailer-B": nil,
1033 "Server-Trailer-C": []string{"valuec"}, 1033 "Server-Trailer-C": []string{"valuec"},
1034 } 1034 }
1035 if !reflect.DeepEqual(res.Trailer, want) { 1035 if !reflect.DeepEqual(res.Trailer, want) {
1036 t.Errorf("Response trailers = %#v; want %#v", res.Trailer, want) 1036 t.Errorf("Response trailers = %#v; want %#v", res.Trailer, want)
1037 } 1037 }
1038 } 1038 }
1039
1040 func TestReferer(t *testing.T) {
1041 tests := []struct {
1042 lastReq, newReq string // from -> to URLs
1043 want string
1044 }{
1045 // don't send user:
1046 {"http://gopher@test.com", "http://link.com", "http://test.com"} ,
1047 {"https://gopher@test.com", "https://link.com", "https://test.co m"},
1048
1049 // don't send a user and password:
1050 {"http://gopher:go@test.com", "http://link.com", "http://test.co m"},
1051 {"https://gopher:go@test.com", "https://link.com", "https://test .com"},
1052
1053 // nothing to do:
1054 {"http://test.com", "http://link.com", "http://test.com"},
1055 {"https://test.com", "https://link.com", "https://test.com"},
1056
1057 // https to http doesn't send a referer:
1058 {"https://test.com", "http://link.com", ""},
1059 {"https://gopher:go@test.com", "http://link.com", ""},
1060 }
1061 for _, tt := range tests {
1062 l, err := url.Parse(tt.lastReq)
1063 if err != nil {
1064 t.Fatal(err)
1065 }
1066 n, err := url.Parse(tt.newReq)
1067 if err != nil {
1068 t.Fatal(err)
1069 }
1070 r := ExportRefererForURL(l, n)
1071 if r != tt.want {
1072 t.Errorf("refererForURL(%q, %q) = %q; want %q", tt.lastR eq, tt.newReq, r, tt.want)
1073 }
1074 }
1075 }
OLDNEW
« no previous file with comments | « src/net/http/client.go ('k') | src/net/http/cookie.go » ('j') | no next file with comments »

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