1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:54:39 -07:00

net/http: make use of maps.Copy

Change-Id: If8e02760fe1fb095ecebc306fd98662a51a1f66f
GitHub-Last-Rev: 7b8099f1fe
GitHub-Pull-Request: golang/go#69426
Reviewed-on: https://go-review.googlesource.com/c/go/+/612736
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Jes Cok 2024-09-12 17:15:58 +00:00 committed by Gopher Robot
parent fc97288e26
commit 998ce1c426
2 changed files with 3 additions and 6 deletions

View File

@ -3683,9 +3683,7 @@ func (h *timeoutHandler) ServeHTTP(w ResponseWriter, r *Request) {
tw.mu.Lock()
defer tw.mu.Unlock()
dst := w.Header()
for k, vv := range tw.h {
dst[k] = vv
}
maps.Copy(dst, tw.h)
if !tw.wroteHeader {
tw.code = StatusOK
}

View File

@ -11,6 +11,7 @@ import (
"fmt"
"internal/godebug"
"io"
"maps"
"net/http/httptrace"
"net/http/internal"
"net/http/internal/ascii"
@ -954,9 +955,7 @@ func mergeSetHeader(dst *Header, src Header) {
*dst = src
return
}
for k, vv := range src {
(*dst)[k] = vv
}
maps.Copy(*dst, src)
}
// unreadDataSizeLocked returns the number of bytes of unread input.