From 71d4458ded3a1e99a0d027ccca6c9d6269a1ab06 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Tue, 20 Jun 2023 19:27:56 +0800 Subject: [PATCH] net/http: declare publicErr as a constant Do the same as the code above: "case err == errTooLarge", declare publicErr as a constant to avoid runtime calls. --- src/net/http/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/http/server.go b/src/net/http/server.go index 8f63a90299..29e862d832 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -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 }