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

Unified Diff: src/pkg/http/serve_test.go

Issue 4248075: code review 4248075: http: move RemoteAddr & UsingTLS from ResponseWriter to... (Closed)
Patch Set: diff -r ca4f5cc00121 https://go.googlecode.com/hg/ Created 14 years ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/http/request.go ('k') | src/pkg/http/server.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/http/serve_test.go
===================================================================
--- a/src/pkg/http/serve_test.go
+++ b/src/pkg/http/serve_test.go
@@ -229,6 +229,7 @@
}
func TestServerTimeouts(t *testing.T) {
+ // TODO(bradfitz): convert this to use httptest.Server
l, err := net.ListenTCP("tcp", &net.TCPAddr{Port: 0})
if err != nil {
t.Fatalf("listen error: %v", err)
@@ -406,3 +407,23 @@
success <- true
}
+
+func TestSetsRemoteAddr(t *testing.T) {
+ ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+ fmt.Fprintf(w, "%s", r.RemoteAddr)
+ }))
+ defer ts.Close()
+
+ res, _, err := Get(ts.URL)
+ if err != nil {
+ t.Fatalf("Get error: %v", err)
+ }
+ body, err := ioutil.ReadAll(res.Body)
+ if err != nil {
+ t.Fatalf("ReadAll error: %v", err)
+ }
+ ip := string(body)
+ if !strings.HasPrefix(ip, "127.0.0.1:") && !strings.HasPrefix(ip, "[::1]:") {
+ t.Fatalf("Expected local addr; got %q", ip)
+ }
+}
« no previous file with comments | « src/pkg/http/request.go ('k') | src/pkg/http/server.go » ('j') | no next file with comments »

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