| 390 | } |
| 391 | |
| 392 | func TestServeFileWithContentEncoding(t *testing.T) { |
| 393 | defer afterTest(t) |
| 394 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 395 | w.Header().Set("Content-Encoding", "foo") |
| 396 | ServeFile(w, r, "testdata/file") |
| 397 | })) |
| 398 | defer ts.Close() |
| 399 | resp, err := http.Get(ts.URL) |
| 400 | if err != nil { |
| 401 | t.Fatal(err) |
| 402 | } |
| 403 | _ = resp.Body.Close() |
| 404 | if g, e := resp.ContentLength, int64(-1); g != e { |
| 405 | t.Errorf("Content-Length mismatch: got %d, want %d", g, e) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestServeIndexHtml(t *testing.T) { |
| 410 | defer afterTest(t) |