1
0
mirror of https://github.com/golang/go synced 2024-09-29 12:04:28 -06:00

add a regression test

This commit is contained in:
Roman Kollár 2019-11-21 23:24:01 +01:00
parent 827fb3f45a
commit 953fdfd49b

View File

@ -6126,6 +6126,39 @@ func TestServerContextsHTTP2(t *testing.T) {
}
}
// Issue 35750: check ConnContext not modifying context for other connections
func TestConnContextNotModifyingAllContexts(t *testing.T) {
setParallel(t)
defer afterTest(t)
type connKey struct{}
ts := httptest.NewUnstartedServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
rw.Header().Set("Connection", "close")
}))
ts.Config.ConnContext = func(ctx context.Context, c net.Conn) context.Context {
if got := ctx.Value(connKey{}); got != nil {
t.Errorf("in ConnContext, unexpected context key = %#v", got)
}
return context.WithValue(ctx, connKey{}, "conn")
}
ts.Start()
defer ts.Close()
var res *Response
var err error
res, err = ts.Client().Get(ts.URL)
if err != nil {
t.Fatal(err)
}
res.Body.Close()
res, err = ts.Client().Get(ts.URL)
if err != nil {
t.Fatal(err)
}
res.Body.Close()
}
// Issue 30710: ensure that as per the spec, a server responds
// with 501 Not Implemented for unsupported transfer-encodings.
func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {