]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: declare publicErr as a constant
authorJes Cok <xigua67damn@gmail.com>
Tue, 20 Jun 2023 11:35:10 +0000 (11:35 +0000)
committerDamien Neil <dneil@google.com>
Thu, 20 Jul 2023 16:57:26 +0000 (16:57 +0000)
Do the same as the code above: "case err == errTooLarge", declare
publicErr as a constant to avoid runtime calls.

Change-Id: I50a9951232c70eff027b0da86c0bbb8bea51acbe
GitHub-Last-Rev: 71d4458ded3a1e99a0d027ccca6c9d6269a1ab06
GitHub-Pull-Request: golang/go#60884
Reviewed-on: https://go-review.googlesource.com/c/go/+/504456
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Olif Oftimis <oftimisolif@gmail.com>
src/net/http/server.go

index 8f63a9029931b1299d6380f0aa59309fd2c00677..29e862d832b9f4eb8ca9c80eeb6cd7b289d0ab07 100644 (file)
@@ -1971,7 +1971,7 @@ func (c *conn) serve(ctx context.Context) {
                                        fmt.Fprintf(c.rwc, "HTTP/1.1 %d %s: %s%s%d %s: %s", v.code, StatusText(v.code), v.text, errorHeaders, v.code, StatusText(v.code), v.text)
                                        return
                                }
-                               publicErr := "400 Bad Request"
+                               const publicErr = "400 Bad Request"
                                fmt.Fprintf(c.rwc, "HTTP/1.1 "+publicErr+errorHeaders+publicErr)
                                return
                        }