mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
net/http: fix data race in test
Fixes #2712. R=golang-dev, dsymonds CC=golang-dev, mpimenov https://golang.org/cl/5543062
This commit is contained in:
parent
ba7dc5de06
commit
92686dda7c
@ -224,9 +224,9 @@ func TestEmptyDirOpenCWD(t *testing.T) {
|
|||||||
|
|
||||||
func TestServeFileContentType(t *testing.T) {
|
func TestServeFileContentType(t *testing.T) {
|
||||||
const ctype = "icecream/chocolate"
|
const ctype = "icecream/chocolate"
|
||||||
override := false
|
override := make(chan bool, 1)
|
||||||
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
|
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
|
||||||
if override {
|
if <-override {
|
||||||
w.Header().Set("Content-Type", ctype)
|
w.Header().Set("Content-Type", ctype)
|
||||||
}
|
}
|
||||||
ServeFile(w, r, "testdata/file")
|
ServeFile(w, r, "testdata/file")
|
||||||
@ -241,8 +241,9 @@ func TestServeFileContentType(t *testing.T) {
|
|||||||
t.Errorf("Content-Type mismatch: got %q, want %q", h, want)
|
t.Errorf("Content-Type mismatch: got %q, want %q", h, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
override <- false
|
||||||
get("text/plain; charset=utf-8")
|
get("text/plain; charset=utf-8")
|
||||||
override = true
|
override <- true
|
||||||
get(ctype)
|
get(ctype)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user