summaryrefslogtreecommitdiff
path: root/src/pkg/http/fs_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/http/fs_test.go')
-rw-r--r--src/pkg/http/fs_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/pkg/http/fs_test.go b/src/pkg/http/fs_test.go
index a89c76d0b..692b9863e 100644
--- a/src/pkg/http/fs_test.go
+++ b/src/pkg/http/fs_test.go
@@ -85,6 +85,30 @@ func TestServeFile(t *testing.T) {
}
}
+func TestServeFileContentType(t *testing.T) {
+ const ctype = "icecream/chocolate"
+ override := false
+ ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+ if override {
+ w.Header().Set("Content-Type", ctype)
+ }
+ ServeFile(w, r, "testdata/file")
+ }))
+ defer ts.Close()
+ get := func(want string) {
+ resp, _, err := Get(ts.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if h := resp.Header.Get("Content-Type"); h != want {
+ t.Errorf("Content-Type mismatch: got %q, want %q", h, want)
+ }
+ }
+ get("text-plain; charset=utf-8")
+ override = true
+ get(ctype)
+}
+
func getBody(t *testing.T, req Request) (*Response, []byte) {
r, err := DefaultClient.Do(&req)
if err != nil {