1
0
mirror of https://github.com/golang/go synced 2024-09-30 03:24:39 -06:00

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.
This commit is contained in:
Jes Cok 2023-06-20 19:27:56 +08:00
parent 98617fd23f
commit 71d4458ded

View 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
}