-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
Go version
go version go1.22.0 windows/amd64
Output of go env in your module/workspace:
not relevantWhat did you do?
Setting *http.Request.Close to true to disable persistent connections in proxyprotocol reverse proxy scenarios. This comes from this issue.
It can be reproduced,
server:
server := httptest.NewUnstartedServer(h2c.NewHandler(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
_, _ = io.WriteString(writer, request.Proto)
}), new(http2.Server)))
fmt.Println(server.Listener.Addr().String())
server.Start()
select {}
client:
func TestSingle(t *testing.T) {
h2t := &http2.Transport{
DialTLSContext: func(ctx context.Context, network, addr string, _ *tls.Config) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, network, addr)
},
AllowHTTP: true,
}
req, _ := http.NewRequest("GET", "http://127.0.0.1:51905", nil)
req.Close = true
for range 100 {
resp, err := h2t.RoundTrip(req)
if err != nil {
t.Error(err)
}
_ = resp.Write(io.Discard)
}
}
The error is http2: client conn not usable.
What did you see happen?
It works for https request but not for h2c requests.
What did you expect to see?
It should work in both cases.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.