diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-04-28 10:35:15 +0200 | 
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-04-28 10:35:15 +0200 | 
| commit | c1ba1a0fec4aed430709030f98a3bdb90bfeea16 (patch) | |
| tree | 3df18657e50a0313ed6defcda30e4474cb28a467 /src/pkg/http/cgi/host_test.go | |
| parent | 7b15ed9ef455b6b66c6b376898a88aef5d6a9970 (diff) | |
| download | golang-c1ba1a0fec4aed430709030f98a3bdb90bfeea16.tar.gz | |
Imported Upstream version 2011.04.27upstream/2011.04.27
Diffstat (limited to 'src/pkg/http/cgi/host_test.go')
| -rw-r--r-- | src/pkg/http/cgi/host_test.go | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/src/pkg/http/cgi/host_test.go b/src/pkg/http/cgi/host_test.go index e8084b113..9ac085f2f 100644 --- a/src/pkg/http/cgi/host_test.go +++ b/src/pkg/http/cgi/host_test.go @@ -271,3 +271,40 @@ Transfer-Encoding: chunked  			expected, got)  	}  } + +func TestRedirect(t *testing.T) { +	if skipTest(t) { +		return +	} +	h := &Handler{ +		Path: "testdata/test.cgi", +		Root: "/test.cgi", +	} +	rec := runCgiTest(t, h, "GET /test.cgi?loc=http://foo.com/ HTTP/1.0\nHost: example.com\n\n", nil) +	if e, g := 302, rec.Code; e != g { +		t.Errorf("expected status code %d; got %d", e, g) +	} +	if e, g := "http://foo.com/", rec.Header().Get("Location"); e != g { +		t.Errorf("expected Location header of %q; got %q", e, g) +	} +} + +func TestInternalRedirect(t *testing.T) { +	if skipTest(t) { +		return +	} +	baseHandler := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { +		fmt.Fprintf(rw, "basepath=%s\n", req.URL.Path) +		fmt.Fprintf(rw, "remoteaddr=%s\n", req.RemoteAddr) +	}) +	h := &Handler{ +		Path:                "testdata/test.cgi", +		Root:                "/test.cgi", +		PathLocationHandler: baseHandler, +	} +	expectedMap := map[string]string{ +		"basepath":   "/foo", +		"remoteaddr": "1.2.3.4", +	} +	runCgiTest(t, h, "GET /test.cgi?loc=/foo HTTP/1.0\nHost: example.com\n\n", expectedMap) +} | 
