Repository: go
Issue: x/net/http2: server too verbose logging in case of "connection reset by peer" on posix platforms
Labels: NeedsInvestigation

### What version of Go are you using (`go version`)?

1.20.3

### Does this issue reproduce with the latest release?

yes

### What operating system and processor architecture are you using (`go env`)?

linux

### What did you do?

we use [krakend](https://www.krakend.io/) (developed in golang) in our RedHat OpenShift environment and have the following problems with the setup and are looking for support on the following questions. We get these (verbose) log lines from krakend (Go-Application) when the OpenShift internal haproxy makes healthchecks (when using more than one pod). This happend very often:
``2023/07/28 08:50:18 http2: server: error reading preface from client <ip>:60524: read tcp <ip>:8443-><ip>:60524: read: connection reset by peer``

Tried to disable these with “http2debug”, but in this case it seems that these GODEBUG values will not be used. Thought this will be the case according to this [RedHat article](https://access.redhat.com/solutions/6999058) - but it does not work:
![image](https://github.com/golang/go/assets/1048543/e8189221-9390-4b0c-ac95-ae98e13245b8)
We reported this issue to the [krakend Developers in the Gophers slack channel](https://gophers.slack.com/archives/CANCJD0V8/p1690534484979029) but it seems to be an issue with the net/http2 package.

## Some "research" in the h2_bundle

I found the source of the loglines [here](https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L4730). The function used is “[condlogf](https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L4573)”.
![image](https://github.com/golang/go/assets/1048543/d42a0efc-c89e-48ac-b8aa-795986747c4b)

Within this function the following if-case seems to be the decision point for selecting the “vlogf” or the “logf” function. “vlogf” evaluates the variable “http2VerboseLogs” for verbose logging which is set by the http2debug GODEBUG value (btw “logf” will not evaluate this value):
![image](https://github.com/golang/go/assets/1048543/1b7d491f-2455-4cc9-a0e8-52299a8effea)

My question: in this case I expected to go into the “vlogf” case (Boring, expected):
![image](https://github.com/golang/go/assets/1048543/f2c7bc0c-ff66-4493-a2a2-941387538311)

This is the function “http2isClosedConnError” with the check if a connection is already closed (with a string contains check):
![image](https://github.com/golang/go/assets/1048543/b801e475-0899-436e-b4b7-d29ee4b1f26d)
Should this not be the case in our “reset by peer” too?

**Interestingly, in the Windows-case this will be checked too (but not in the posix platform case):**
![image](https://github.com/golang/go/assets/1048543/888e66c4-d1f7-4c6b-8f8c-0b66fb336c33)
**Should this check for the string “use of closed network connection” not be improved with [errors.Is](https://github.com/golang/go/blob/master/src/errors/wrap.go#L44)? It seems to be possible to check for “reset by peer” error with errors.Is(err, syscall.ECONNRESET).**

What do you think?

### What did you expect to see?
If not set the GODEBUG value http2debug=1: No verbose log lines in case of "connection reset by peer".
If set the GODEBUG value http2debug=1: Verbose log lines in case of "connection reset by peer".

### What did you see instead?
Not set the GODEBUG value http2debug=1: Verbose log lines in case of "connection reset by peer".